private IBookClubMembershipRepository GetFakeBookClubMembershipRepository() { var repository = new FakeBookClubMembershipRepository(); var newMembership = BookClubMembership.Create(3344656); repository.Save(newMembership); return(repository); }
public void BookClubMembershipCreate() { int customerId = 344656; BookClubMembership sut = BookClubMembership.Create(customerId); sut.Id.ShouldBe(customerId); }
public async Task BookClubPointsServiceHandlesProcessedPurchasedOrderForExistingMembership() { int customerId = 344656; AwardedCustomerPoints awardedCustomerPoints = new AwardedCustomerPoints(); var mockMediator = new Mock <IMediator>(); mockMediator.Setup(m => m.Send(It.IsAny <AwardCustomerPoints>(), It.IsAny <CancellationToken>())) .ReturnsAsync(awardedCustomerPoints) .Verifiable("Awarded book club membership points."); ProcessedPurchaseOrder processedPurchaseOrder = new ProcessedPurchaseOrder { CustomerId = customerId, PurchaseOrderId = 4567890, Items = new List <ItemLineRequest> { new ItemLineRequest { Description = "Comprehensive First Aid Training", Type = ItemLineType.Product, Category = ItemLineCategory.Book }, new ItemLineRequest { Description = "The Girl on the Train", Type = ItemLineType.Product, Category = ItemLineCategory.Video }, } }; IBookClubMembershipRepository fakeRepo = GetFakeBookClubMembershipRepository(BookClubMembership.Create(customerId)); BookClubPointsService sut = new BookClubPointsService(mockMediator.Object, fakeRepo); await sut.Handle(processedPurchaseOrder); mockMediator.Verify(m => m.Send(It.Is <AwardCustomerPoints>(a => a.Points == 5), It.IsAny <CancellationToken>()), Times.Once); }