public async Task LoadCountersAsyncShouldLoadTheCountersFromTheDatabase() { _mockDatabaseHelper.Setup(d => d.GetAllCountersAsync()).ReturnsAsync(new List<Counter> { _monkeyCounter, _platypusCounter }); var vm = new CountersViewModel(_mockDatabaseHelper.Object, _mockNavigationService.Object, _mockDialogService.Object); await vm.LoadCountersAsync(); vm.Counters.Should().HaveCount(2); vm.Counters.Should().Contain(c => Matches(c, _monkeyCounter)); vm.Counters.Should().Contain(c => Matches(c, _platypusCounter)); }
public void CountersChangingInTheDatabaseShouldReloadTheCounters() { var vm = new CountersViewModel(_mockDatabaseHelper.Object, _mockNavigationService.Object, _mockDialogService.Object); _mockDatabaseHelper.Raise(d => d.CountersChanged += null, new EventArgs()); _mockDatabaseHelper.Verify(d => d.GetAllCountersAsync(), Times.Once); GC.KeepAlive(vm); }
public void ExecutingAddNewCounterCommandShouldNavigateToTheNewCounterActivity() { var vm = new CountersViewModel(_mockDatabaseHelper.Object, _mockNavigationService.Object, _mockDialogService.Object); vm.AddNewCounterCommand.Execute(null); _mockNavigationService.Verify(n => n.NavigateTo(ViewModelLocator.NewCounterPageKey), Times.Once); }