예제 #1
0
        public async Task TestPersonDeleteEventHandler()
        {
            //Arrange
            await SetupData();

            var handler = new PersonDeletedEventHandler(PersonFamilyTreeRepository);
            var @event  = new PersonDeletedEvent()
            {
                Person = CreatePerson2(),
            };

            //Act
            await handler.Handle(@event);

            //Assert
            var result = await PersonFamilyTreeRepository.GetFamilyTree("5", 2);

            Assert.Empty(result.Nodes.Where(item => item.Id == "3"));

            result = await PersonFamilyTreeRepository.GetFamilyTree("1", 2);

            Assert.Empty(result.Nodes.Where(item => item.Id == "3"));

            result = await PersonFamilyTreeRepository.GetFamilyTree("2", 2);

            Assert.Empty(result.Nodes.Where(item => item.Id == "3"));
        }
예제 #2
0
        public async Task TestPersonDeletedEventHandler()
        {
            //Arrange
            var handler = new PersonDeletedEventHandler(PersonCategoryRepository,
                                                        PersonPerCityCounterRepository, TransactionManager);

            var @event = new PersonDeletedEvent()
            {
                Person = CreatePerson2(),
            };

            //Act
            var result = await GetCategory(@event.Person);

            var expected = result[0];

            expected.Count = Math.Max(expected.Count - 1, 0);

            await handler.Handle(@event);

            result = await GetCategory(@event.Person);

            var obtained = result[0];

            //Assert
            Assert.Equal(expected.Count, obtained.Count);
        }