public async Task CharityActionCreatedEventHandler_Handle_Returns_Success() { DonationsContext.OpenInMemoryConnection(); try { var Charity = new DAL.Charity { CharityKey = Guid.NewGuid(), Name = "Test", ChartityActions = new List <DAL.CharityAction>(), }; var Event = new CharityActionCreatedEvent { Category = Core.Enums.Category.EnvironmentAndNatureConservation, CharityActionKey = Guid.NewGuid(), CoverImage = "No image given", IBAN = "NotReallyAnIBAN", Description = "This is a very good testing description", CharityKey = Charity.CharityKey, Name = "TestNameAction", UserKeys = new List <UserKey> { new UserKey { Key = Guid.NewGuid() } }, ThankYou = "ThankYou" }; using (var context = DonationsContext.GetInMemoryContext()) { context.Charities.Add(Charity); await context.SaveChangesAsync(); var handler = new CharityActionCreatedEventHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); await handler.ConsumeAsync(Event); } using (var context = DonationsContext.GetInMemoryContext()) { Assert.AreEqual(1, context.CharityActions.Count()); Assert.AreEqual(Event.CharityActionKey, context.CharityActions.Single().CharityActionKey); Assert.AreEqual(Event.ActionEndDateTime, context.CharityActions.Single().ActionEndDateTime); Assert.AreEqual(Event.ThankYou, context.CharityActions.Single().ThankYou); Assert.AreEqual(Event.CoverImage, context.CharityActions.Single().CoverImage); Assert.AreEqual(Event.Name, context.CharityActions.Single().Name); } } finally { DonationsContext.CloseInMemoryConnection(); } }
public async Task CharityActionCreatedEventHandler_Handle_Returns_Success() { SearchContext.OpenInMemoryConnection(); try { var Event = new CharityActionCreatedEvent { Category = Core.Enums.Category.EnvironmentAndNatureConservation, CharityActionKey = Guid.NewGuid(), CoverImage = "No image given", IBAN = "NotReallyAnIBAN", Description = "This is a very good testing description", CharityKey = Guid.NewGuid(), Name = "TestNameAction", UserKeys = new List <UserKey> { new UserKey { Key = Guid.NewGuid() } } }; using (var context = SearchContext.GetInMemoryContext()) { var handler = new CharityActionCreatedEventHandler(context); await handler.ConsumeAsync(Event); } using (var context = SearchContext.GetInMemoryContext()) { Assert.AreEqual(1, context.Content.Count()); Assert.AreEqual(Event.CharityActionKey, context.Content.Single().CharityActionKey); Assert.AreEqual(Event.CharityKey, context.Content.Single().CharityKey); Assert.AreEqual(Event.CoverImage, context.Content.Single().Image); Assert.AreEqual(Event.Category, context.Content.Single().Category); Assert.AreEqual(Event.Description, context.Content.Single().Description); Assert.AreEqual(Core.Enums.SearchContentType.CharityAction, context.Content.Single().Type); } } finally { SearchContext.CloseInMemoryConnection(); } }