public async void EventAfterDetailSaved_When_Called_From_AccountManagerDetailViewModel_Should_Update_ListAccountManager() { //Arrange var anyInTheMockDefinedCustomerId = 2; var eventAfterDetailSaved = new EventAfterDetailSaved(); _eventAggregatorMock.Setup(ea => ea.GetEvent <EventAfterDetailSaved>()).Returns(eventAfterDetailSaved); _customerDetailViewModel = new CustomerDetailViewModel(_customerRepositoryMock.Object, _eventAggregatorMock.Object, _messageDialogServiceMock.Object, _accountManagerLookupDataServiceMock.Object); await _customerDetailViewModel.LoadAsync(anyInTheMockDefinedCustomerId); //Mockup list contains 3 entries + 1 NullLookupItem = 4 items: Assert.Equal(4, _customerDetailViewModel.LookupItemsAccountManager.Count()); //Act //Change Mockup list to contain 4 entries isntead of 3 before: _lookupItemAccountManagerList = new List <LookupItem> { new LookupItem { Id = 1, DisplayMember = "Carl Manager" }, new LookupItem { Id = 2, DisplayMember = "Fritz Manager" }, new LookupItem { Id = 3, DisplayMember = "Fred Manager" }, new LookupItem { Id = 4, DisplayMember = "Any OtherManager" } }; var expectedNumberOfAccountManagersAfterAct = _lookupItemAccountManagerList.Count() + 1; // e Entries + 1 NullLookupItem _accountManagerLookupDataServiceMock.Setup(dp => dp.GetEntityLookupAsync()).ReturnsAsync(_lookupItemAccountManagerList); //Simulate an EventafterDetailSaved from an AccountManagerDetailViewModel: eventAfterDetailSaved.Publish(new EventAfterDetailSavedArgs { Id = 4, ViewModelName = nameof(AccountManagerDetailViewModel) }); //Assert //ListLookupAccountManager should become 5 = 4 entries + 1 NullLookupItem Assert.Equal(expectedNumberOfAccountManagersAfterAct, _customerDetailViewModel.LookupItemsAccountManager.Count()); }
public async void EventAfterSavedCustomer_When_Published_Should_Call_ReLoadAsync() { //Arrange //Load customerNavigationItemViewModels to use the first item for this test: await _customerNavigationViewModel.LoadAsync(id : 0); var customerNavigationItemViewModel = _customerNavigationViewModel.EntityNavigationItemViewModels.First(); var customerNavigationItemViewModelItemId = customerNavigationItemViewModel.Id; var expectedDisplayMember = customerNavigationItemViewModel.DisplayMember; //Act customerNavigationItemViewModel.DisplayMember = "Different Name"; _eventAfterSavedCustomer.Publish( new EventAfterDetailSavedArgs { Id = customerNavigationItemViewModelItemId, ViewModelName = nameof(CustomerDetailViewModel) }); Assert.Equal("Different Name", customerNavigationItemViewModel.DisplayMember); customerNavigationItemViewModel = _customerNavigationViewModel.EntityNavigationItemViewModels.First(); Assert.Equal(expectedDisplayMember, customerNavigationItemViewModel.DisplayMember); }