Beispiel #1
0
        public async Task Can_Clone_Wishlist_And_It_Removes_Present_Ideas()
        {
            var idOfCreator = Guid.NewGuid();
            var secondPersonId = Guid.NewGuid();
            var thirdPersonId = Guid.NewGuid();
            var presentId = Guid.NewGuid();
            
            var wishlist =
                new WishlistBuilder(idOfCreator)
                    .AddPerson(idOfCreator)
                    .AddPerson(secondPersonId)
                    .AddPerson(thirdPersonId)
                    .AddPresentIdea(secondPersonId, "desc 1", presentId)
                    .AddClaimer(presentId, thirdPersonId)
                    .Build();

            var inMemoryWishlistRepository = new InMemoryWishlistRepository();
            var wishlistCloner = new WishlistCloner(inMemoryWishlistRepository);
            
            await inMemoryWishlistRepository.Save(wishlist);
            await wishlistCloner.Clone(wishlist.Id, "New name");

            inMemoryWishlistRepository._wishlists.Count.Should().Be(2);
            var newWishlist = inMemoryWishlistRepository._wishlists.Single(s => s.Key != wishlist.Id).Value;
            var newPeople = newWishlist.People.Select(s => s.PersonId);
            newPeople.Should().BeEquivalentTo(new [] {idOfCreator, secondPersonId, thirdPersonId});

            newWishlist.People.SelectMany(s => s.PresentIdeas).Should().BeEmpty();
            newWishlist.Name.Should().Be("New name");
        }
        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
            });
        }
Beispiel #3
0
        public async Task Saves_WishList_And_Loads_Wishlist()
        {
            var repo = new InMemoryWishlistRepository();
            var wishlist = Wishlist.Create("Asd", Guid.NewGuid());
            await repo.Save(wishlist);

            var reloadedWishlist = await repo.Load(wishlist.Id);
            reloadedWishlist.Should().NotBeNull();
        }