Skip to content

Commit

Permalink
Adapt unit tests & freeze moq of timespanformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveyJonesBitPail committed Dec 1, 2023
1 parent f03a169 commit d2a0f97
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace netczicompressTests.ViewModels;
using System.ComponentModel;

using netczicompress.ViewModels;
using netczicompress.ViewModels.Formatters;

/// <summary>
/// Tests for <see cref="AggregateStatisticsViewModel"/>.
Expand All @@ -23,7 +24,7 @@ public void Properties_AfterCreation_HaveExpectedValues()
var sut = fixture.Create<AggregateStatisticsViewModel>();

// ASSERT
sut.Should().BeEquivalentTo(AggregateStatistics.Empty, options => options.Excluding(o => o.Duration));
sut.Should().BeEquivalentTo(AggregateStatistics.Empty);
}

[Fact]
Expand All @@ -48,7 +49,7 @@ public void OnNext_WhenCalled_ChangesPropertyValues()
Times.Once);
propertyListener.VerifyNoOtherCalls();

sut.Should().BeEquivalentTo(newValue, options => options.Excluding(o => o.Duration));
sut.Should().BeEquivalentTo(newValue);
}

[Fact]
Expand Down Expand Up @@ -81,8 +82,15 @@ private static void WhenCalled_DoesNotDoAnything(Action<IObserver<AggregateStati
{
// ARRANGE
IFixture fixture = CreateFixture();

var timeSpanFormatterMock = fixture.Freeze<Mock<ITimeSpanFormatter>>();
timeSpanFormatterMock
.Setup(x => x.FormatTimeSpan(It.IsAny<TimeSpan>()))
.Returns(string.Empty);

var oldValue = fixture.Create<AggregateStatistics>();
var sut = fixture.Create<AggregateStatisticsViewModel>();

sut.OnNext(oldValue);

// ACT
Expand All @@ -92,8 +100,8 @@ private static void WhenCalled_DoesNotDoAnything(Action<IObserver<AggregateStati
// ASSERT
monitor.OccurredEvents.Should().BeEmpty();

// Duration formatting is tested in <see cref="OnNext_WithNewDuration_HasNiceFormattedPropertySet"/>
sut.Should().BeEquivalentTo(oldValue, options => options.Excluding(o => o.Duration));
sut.Should().BeEquivalentTo(oldValue);
sut.FormattedDuration.Should().BeEquivalentTo(string.Empty);
}

private static IFixture CreateFixture()
Expand Down

0 comments on commit d2a0f97

Please sign in to comment.