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 CloneWishlistHandler(WishlistCloner cloner, IMediator mediator) { _cloner = cloner; _mediator = mediator; }