Example #1
0
        public async Task CharityCreatedEventHandler_Handle_Returns_Success()
        {
            SearchContext.OpenInMemoryConnection();

            try
            {
                var Event = new CharityCreatedEvent()
                {
                    Category      = Core.Enums.Category.EnvironmentAndNatureConservation,
                    CharityKey    = Guid.NewGuid(),
                    CoverImage    = "No image given",
                    Email         = "*****@*****.**",
                    IBAN          = "NotReallyAnIBAN",
                    KVKNumber     = "10",
                    Name          = "TestName",
                    Url           = "test",
                    OwnerUserName = "******",
                    Slogan        = "This is a very good testing slogan",
                };

                using (var context = SearchContext.GetInMemoryContext())
                {
                    var handler = new CharityCreatedEventHandler(context);
                    await handler.ConsumeAsync(Event);
                }

                using (var context = SearchContext.GetInMemoryContext())
                {
                    Assert.AreEqual(1, context.Content.Count());
                    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.Slogan, context.Content.Single().Description);
                    Assert.AreEqual(Core.Enums.SearchContentType.Charity, context.Content.Single().Type);
                    Assert.AreEqual(Event.Name, context.Content.Single().CharityName);
                }
            }
            finally
            {
                SearchContext.CloseInMemoryConnection();
            }
        }
        public async Task CharityCreatedEventHandler_Handle_Returns_Success()
        {
            DonationsContext.OpenInMemoryConnection();

            try
            {
                var Event = new CharityCreatedEvent()
                {
                    Category      = Core.Enums.Category.EnvironmentAndNatureConservation,
                    CharityKey    = Guid.NewGuid(),
                    CoverImage    = "No image given",
                    Email         = "*****@*****.**",
                    IBAN          = "NotReallyAnIBAN",
                    KVKNumber     = "10",
                    Name          = "TestName",
                    Url           = "test",
                    OwnerUserName = "******",
                    Slogan        = "This is a very good testing slogan",
                    ThankYou      = "ThankYou"
                };

                using (var context = DonationsContext.GetInMemoryContext())
                {
                    var handler = new CharityCreatedEventHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile()));
                    await handler.ConsumeAsync(Event);
                }

                using (var context = DonationsContext.GetInMemoryContext())
                {
                    Assert.AreEqual(1, context.Charities.Count());
                    Assert.AreEqual(Event.Name, context.Charities.Single().Name);
                    Assert.AreEqual(Event.ThankYou, context.Charities.Single().ThankYou);
                    Assert.AreEqual(Event.CoverImage, context.Charities.Single().CoverImage);
                }
            }
            finally
            {
                DonationsContext.CloseInMemoryConnection();
            }
        }