public async Task TestPersonUpdateEventHandler() { //Arrange await SetupData(); var handler = new PersonUpdatedEventHandler(PersonFamilyTreeRepository); var @event = new PersonUpdatedEvent() { OldPersonData = CreatePerson2(), NewPersonData = CreatePerson3(), }; //Act await handler.Handle(@event); //Assert var result = await PersonFamilyTreeRepository.GetFamilyTree("3", 2); Assert.NotEmpty(result.Nodes.Where(item => item.Id == "5")); Assert.Empty(result.Nodes.Where(item => item.Id == "1")); Assert.Empty(result.Nodes.Where(item => item.Id == "2")); }
public async Task TestPersonUpdatedEventHandler() { //Arrange var handler = new PersonUpdatedEventHandler(PersonCategoryRepository, PersonPerCityCounterRepository, TransactionManager); var @event = new PersonUpdatedEvent() { OldPersonData = CreatePerson1(), NewPersonData = CreatePerson2() }; //Act var resultOld = await GetCategory(@event.OldPersonData); var resultNew = await GetCategory(@event.NewPersonData); var expectedOld = resultOld[0]; var expectedNew = resultNew[0]; expectedOld.Count = Math.Max(expectedOld.Count - 1, 0); expectedNew.Count++; await handler.Handle(@event); resultOld = await GetCategory(@event.OldPersonData); resultNew = await GetCategory(@event.NewPersonData); var obtainedOld = resultOld[0]; var obtainedNew = resultNew[0]; //Assert Assert.Equal(expectedOld.Count, obtainedOld.Count); Assert.Equal(expectedNew.Count, obtainedNew.Count); }