public void SelectedSearchResult_NavigatesToAddressViewModel_WhenResultModelsAddressIsNull() { // Act var viewModel = ClassUnderTest; var homeResultModel = new HomeResultModel(null); var workResultModel = new WorkResultModel(null); viewModel.SearchResults = new ObservableCollection <IAutoCompleteResultModel> { homeResultModel, workResultModel }; var navigationServiceMoq = GetMock <INavigationService>(); // Arrange Scheduler.Schedule(() => viewModel.SelectedSearchResult = viewModel.SearchResults[0]); Scheduler.Schedule(() => viewModel.SelectedSearchResult = viewModel.SearchResults[1]); Scheduler.Start(); // Assert navigationServiceMoq.Verify(x => x.NavigateToSearchView(It.IsAny <Action <HomeLocationEditorViewModel> >()), Times.Once); navigationServiceMoq.Verify(x => x.NavigateToSearchView(It.IsAny <Action <WorkLocationEditorViewModel> >()), Times.Once); }
public void Search_ReturnsHomeAndWorkResultModel_WhenTextSearchIsEmpty(HomeResultModel homeResultModel, WorkResultModel workResultModel, SetLocationOnMapResultModel setLocationOnMapResultModel) { // Act var viewModel = ClassUnderTest; var autoCompleteResultProviderMoq = GetMock <IEmptyAutocompleteResultProvider>(); autoCompleteResultProviderMoq.Setup(x => x.GetHomeResultModel()).Returns(homeResultModel); autoCompleteResultProviderMoq.Setup(x => x.GetWorkResultModel()).Returns(workResultModel); autoCompleteResultProviderMoq.Setup(x => x.GetSetLocationOnMapResultModel()).Returns(setLocationOnMapResultModel); // Arrange Scheduler.Schedule(() => viewModel.SearchText = string.Empty); Scheduler.Start(); var result = viewModel.SearchResults; // Assert Assert.AreEqual(homeResultModel, result[0]); Assert.AreEqual(workResultModel, result[1]); Assert.AreEqual(setLocationOnMapResultModel, result[2]); }