Ejemplo n.º 1
0
        public void Setup()
        {
            this.inMemoryRepository        = new InMemoryWishlistRepository();
            this.inMemorySummaryRepository = new InMemoryWishlistSummaryRepository();
            this.client = _factory
                          .WithWebHostBuilder(t =>
            {
                t.UseSetting("ASPNETCORE_ENVIRONMENT", "test");
                t.ConfigureServices(s =>
                {
                    s.RemoveAll(typeof(IDocumentStore));
                    s.RemoveAll(typeof(IWishlistRepository));
                    s.RemoveAll(typeof(IUserRepository));



                    s.Add((new ServiceDescriptor(typeof(IWishlistRepository), inMemoryRepository)));
                    s.Add((new ServiceDescriptor(typeof(IUserRepository), inMemorySummaryRepository)));
                });
            })

                          .CreateClient(new WebApplicationFactoryClientOptions
            {
                AllowAutoRedirect = false
            });
        }
Ejemplo n.º 2
0
        public async Task Maps_Name_From_Email_In_Claim()
        {
            var presentId = Guid.NewGuid();
            var idOfCreator = Guid.NewGuid();
            var secondPersonId = Guid.NewGuid();
            var thirdPersonId = Guid.NewGuid();


            var wishlist =
                new WishlistBuilder(idOfCreator)
                    .AddPerson(secondPersonId)
                    .AddPerson(thirdPersonId)
                    .AddPresentIdea(secondPersonId, "desc 1", presentId)
                    .AddClaimer(presentId, thirdPersonId)
                    .Build();


            IUserRepository wishlistSummariesRepo = new InMemoryWishlistSummaryRepository();
            await wishlistSummariesRepo.AddWishlistToPerson(idOfCreator, wishlist.Id);
            await wishlistSummariesRepo.AddWishlistToPerson(secondPersonId, wishlist.Id);
            await wishlistSummariesRepo.AddWishlistToPerson(thirdPersonId, wishlist.Id);
            await wishlistSummariesRepo.SetEmailAndName(secondPersonId, "*****@*****.**", "Second person");
            await wishlistSummariesRepo.SetEmailAndName(thirdPersonId, "*****@*****.**", "Third person");

            var mapper = new WishlistMapper(wishlistSummariesRepo);
            var model = await mapper.Map(wishlist);
            var presentIdeaModels = model.People
                .Single(s => s.PersonId == secondPersonId)
                .PresentIdeas;
            var claimer = presentIdeaModels
                .Single(s => s.Id == presentId);

            claimer.ClaimerName.Should().Be("Third person");            
            claimer.ClaimerEmail.Should().Be("*****@*****.**");
        }