Ejemplo n.º 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"));
        }
Ejemplo n.º 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);
        }
        public void Handle(PersonDeletedEvent @event, DatabaseContext db)
        {
            var personReadModel = db.Set <PersonReadModel>()
                                  .FirstOrDefault(readModel => readModel.AggregateRootId == @event.Id);

            if (personReadModel != null)
            {
                db.Set <PersonReadModel>().Remove(personReadModel);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Delete Reporting Data
 /// </summary>
 /// <param name="evt"></param>
 public void Handle(PersonDeletedEvent evt)
 {
     _reportingRepository.Delete <Person>(evt.Id);
 }