Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
 public void Creating_A_Wishlist_Adds_An_Id_And_Initial_User()
 {
     var idOfCreator = Guid.NewGuid();
     var wishlist = Wishlist.Create("Eds test wishlist", idOfCreator);
     wishlist.Id.Should().NotBeEmpty();
     wishlist.Name.Should().Be("Eds test wishlist");            
     wishlist.GetPeople().First().PersonId.Should().Be(idOfCreator);             
     wishlist.GetPeople().First().Giftee.Should().Be(true);      
     wishlist.CreatorId.Should().Be(idOfCreator);
 }
Exemplo n.º 3
0
        public void Can_Add_Item_To_Wishlist()
        {
            var idOfCreator = Guid.NewGuid();
            
            var wishlist = Wishlist.Create("Eds test wishlist", idOfCreator);
            wishlist.AddGiftIdea(idOfCreator, "My first present");

            var person = wishlist.GetPerson(idOfCreator);

            person.PresentIdeas.Count.Should().Be(1);
            person.PresentIdeas.Single().Description.Should().Be("My first present");
        }
Exemplo n.º 4
0
 public void Can_Add_Person_With_Email_And_Name_To_Wishlist()
 {
     var idOfCreator = Guid.NewGuid();
     var newPersonId = Guid.NewGuid();
     var wishlist = Wishlist.Create("Eds test wishlist", idOfCreator);
     wishlist.AddPerson(newPersonId, true);
     
     wishlist.GetPeople().Should().BeEquivalentTo(new []
     {
         new WishlistPerson() { PersonId = idOfCreator, Giftee = true},
         new WishlistPerson() { PersonId = newPersonId, Giftee = true}
     });
 }
Exemplo n.º 5
0
        public void Can_Remove_Item_From_Wishlist()
        {
            var idOfCreator = Guid.NewGuid();
            
            var wishlist = Wishlist.Create("Eds test wishlist", idOfCreator);
            wishlist.AddGiftIdea(idOfCreator, "My first present");
            var present = wishlist.GetPerson(idOfCreator).PresentIdeas.Single();
            wishlist.RemoveGiftIdea(idOfCreator, present.Id);
            
            var person = wishlist.GetPerson(idOfCreator);

            person.PresentIdeas.Count.Should().Be(0);
        }
Exemplo n.º 6
0
        public async Task Test_AddPerson_Wishlist()
        {
            var idOfCreator = Guid.NewGuid();
            var wishlist    = Wishlist.Create("a", idOfCreator, true);

            await this.inMemoryRepository.Save(wishlist);

            await inMemorySummaryRepository.CreatePerson(idOfCreator, "a", "a");

            await inMemorySummaryRepository.AddWishlistToPerson(idOfCreator, wishlist.Id);

            var response = await client.PostAsync($"/wishlist/addPerson?wishlistId={wishlist.Id.ToString()}&name=Ed&email=ed&isGiftee=true", new StringContent(""));

            response.EnsureSuccessStatusCode();
            inMemoryRepository._wishlists.Count.Should().BeGreaterThan(0);
            inMemoryRepository._wishlists.Single().Value.People.Count.Should().Be(2);
            var creatorDetails = await inMemorySummaryRepository.GetUser(idOfCreator);

            creatorDetails.Wishlists.Count().Should().Be(1);
        }
 public async Task<Guid> CreateTestWishlist([FromBody] CreateWishlistRequestModel req)
 {
     var wishlist = Wishlist.Create("[Test] " + req.title, req.creatorId);
    await _repository.Save(wishlist);
    return wishlist.Id;
 }