Skip to content

Commit

Permalink
Add SaveSettingsCommand unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
rguida committed May 20, 2024
1 parent 6b73a44 commit 8cb3a50
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions MMExNotifier.Tests/MainViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,33 @@ public void OnDatabaseError_ShouldShowErrorMessage()

mockNotificationService.Verify();
}


[Test]
public void SavingAppSettings_ShouldReloadExpiringBills()
{
mockDatabaseService.Setup(x => x.ExpiringBills).Returns(
new List<ExpiringBill>
{
new()
{
BillId=1,
CategoryName="testCategory",
PayeeName="TestPayee",
NextOccurrenceDate=new DateTime(2024,6,1)
}
});

mockNotificationService.Setup(
x => x.ShowErrorNotification(It.IsAny<string>())
);

var mainViewModel = new MainViewModel(mockAppConfiguration.Object, mockNotificationService.Object, mockDatabaseService.Object);
mainViewModel.Activate();
mainViewModel.SaveSettingsCommand.Execute(null);

mockNotificationService.Verify();
mockDatabaseService.Verify(x => x.ExpiringBills, Times.Exactly(2));
}
}
}
2 changes: 2 additions & 0 deletions MMExNotifier/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
Severity="Informational"
Style="{DynamicResource IconInfoBadgeStyle}" />

<!-- Bill expires in two or fewer days -->
<Grid>
<Grid.Style>
<Style TargetType="{x:Type Grid}">
Expand All @@ -179,6 +180,7 @@
Style="{DynamicResource IconInfoBadgeStyle}" />
</Grid>

<!-- Bill expired -->
<Grid>
<Grid.Style>
<Style TargetType="{x:Type Grid}">
Expand Down

0 comments on commit 8cb3a50

Please sign in to comment.