public void SearchOrganizationInformationViewModelTest_Instantiation() { // Arrange Mock <ILog> logger = new Mock <ILog>(); Mock <IRestQuery> query = new Mock <IRestQuery>(); // Act SearchOrganizationInformationViewModel target = new SearchOrganizationInformationViewModel(logger.Object, mapper, query.Object); // Assert Assert.IsNotNull(target.Model); Assert.IsNotNull(target.SearchCommand); }
private static SearchOrganizationInformationViewModel GetViewModel() { Mock <ILog> logger = new Mock <ILog>(); Organization org = new Organization(); Mock <IRestQuery> query = new Mock <IRestQuery>(); query.Setup(s => s.Get <Organization>(It.IsAny <string>())).Returns(org); SearchOrganizationInformationViewModel target = new SearchOrganizationInformationViewModel(logger.Object, mapper, query.Object); return(target); }
public void SearchOrganizationInformationViewModelTest_SendsEventWhenSearchResultIsReceived() { // Arrange PubSub <ObservableCollection <OrganizationModel> > .RegisterEvent(EventNames.SearchResultReceivedEvent, this.SearchResultReceivedEventHandler); SearchOrganizationInformationModel search = new SearchOrganizationInformationModel { SearchType = SearchType.OrganizationNumber, SearchText = "910021451" }; SearchOrganizationInformationViewModel target = GetViewModel(); // Act target.SearchCommand.Execute(search); // Wait for tasks to complete. Thread.Sleep(1000); // Asserts Assert.IsNotNull(this.searchResult); }
public void SearchOrganizationInformationViewModelTest_PhoneNumberSearch_SearchResultIsUpdated() { // Arrange PubSub <ObservableCollection <OrganizationModel> > .RegisterEvent(EventNames.SearchResultReceivedEvent, this.SearchResultReceivedEventHandler); Mock <ILog> logger = new Mock <ILog>(); IList <Organization> orgs = new List <Organization>(); orgs.Add(new Organization()); Mock <IRestQuery> query = new Mock <IRestQuery>(); query.Setup(s => s.Get <Organization>(It.Is <KeyValuePair <string, string> >(pair => pair.Key == SearchType.PhoneNumber.ToString()))).Returns(orgs); SearchOrganizationInformationModel search = new SearchOrganizationInformationModel { SearchType = SearchType.Smart, SearchText = "47419641" }; SearchOrganizationInformationViewModel target = new SearchOrganizationInformationViewModel(logger.Object, mapper, query.Object); // Act target.SearchCommand.Execute(search); // Wait for tasks to complete. Thread.Sleep(1000); // Assert query.VerifyAll(); Assert.IsNotNull(this.searchResult); Assert.IsNotNull(target.SearchCommand); Assert.IsNotNull(target.Model); Assert.IsTrue(search.LabelText.Contains(Resources.PhoneNumber) && search.LabelText.Contains(search.SearchText)); }