Ejemplo n.º 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");
        }
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("*****@*****.**");
        }
Ejemplo n.º 3
0
        public void Can_Remove_Person()
        {
            var idOfCreator = Guid.NewGuid();
            var secondPersonId = Guid.NewGuid();
            
            var wishlist =
                new WishlistBuilder(idOfCreator)
                    .AddPerson(idOfCreator)
                    .AddPerson(secondPersonId, true)
                    .Build();

            wishlist.RemovePerson(secondPersonId);

            wishlist.People.Count.Should().Be(1);
        }
Ejemplo n.º 4
0
        public void Can_Change_Is_Claimer()
        {
            var idOfCreator = Guid.NewGuid();
            var secondPersonId = Guid.NewGuid();
            
            var wishlist =
                new WishlistBuilder(idOfCreator)
                    .AddPerson(idOfCreator)
                    .AddPerson(secondPersonId, true)
                    .Build();

            wishlist.ChangeIsGiftee(secondPersonId, false);
            wishlist.GetPerson(secondPersonId).Giftee.Should().BeFalse();
            
            wishlist.ChangeIsGiftee(secondPersonId, true);
            wishlist.GetPerson(secondPersonId).Giftee.Should().BeTrue();
        }
Ejemplo n.º 5
0
        public void Can_Claim_Present()
        {
            var idOfCreator = Guid.NewGuid();

            var secondPersonid = Guid.NewGuid();
            var presentId = Guid.NewGuid();
            var wishlist =
                new WishlistBuilder(idOfCreator)
                    .AddPerson(secondPersonid)
                    .AddPerson(idOfCreator)
                    .AddPresentIdea(idOfCreator, "asd", presentId)
                    .Build();
            
            var presentIdea = wishlist.GetPerson(idOfCreator).PresentIdeas.Single();
            wishlist.ClaimGift(presentIdea.Id, secondPersonid);

            presentIdea.ClaimerId.Should().Be(secondPersonid);
        }