public virtual void runShouldDoNothingIfNoMembershipsInOrder() { LineItem[] lineItems = new LineItem[] { new LineItem("item1", "item1", new ProductCategory[] { ProductCategory.Physical }) }; var customer = new Mock <Customer>().Object; Order order = new Order(customer, lineItems, null); Payment payment = new Payment(order); MembershipRepository service = new Mock <MembershipRepository>().Object; NotificationService notificationService = new Mock <NotificationService>().Object; Membership membership = new Membership("item1", null); PaymentHandler sut = new MembershipActivateHandler(service, notificationService); sut.run(payment); customer.addMembership(membership, notificationService); }
public virtual void runShouldNotifyCustomer() { LineItem[] lineItems = new LineItem[] { new LineItem("item1", "item1", new ProductCategory[] { ProductCategory.Membership }) }; var customer = new Mock <Customer>().Object; Order order = new Order(customer, lineItems, null); Payment payment = new Payment(order); MembershipRepository repo = new Mock <MembershipRepository>().Object; Membership membership = new Membership("item1", null); //when(repo.findBySku("item1")).thenReturn(membership); NotificationService notificationService = new Mock <NotificationService>().Object; PaymentHandler sut = new MembershipActivateHandler(repo, notificationService); sut.run(payment); notificationService.notify(customer, membership); //verify(notificationService, times(1)).notify(customer, membership); }