Exemplo n.º 1
0
        public async Task MembershipActivationRule_PhysicalProductsArentActivated()
        {
            // Arrange
            Mock <ICustomerService> mockCustomerService = TestFactory.CreateMockCustomerService();
            IRule          membershipActivationRule     = TestFactory.CreateMembershipActivationRule(mockCustomerService.Object);
            RulesProcessor rulesProcessor = new RulesProcessor(new List <IRule>()
            {
                membershipActivationRule
            });
            PurchaseOrder purchaseOrder = TestFactory.GetPurchaseOrder(TestFactory.GetPurchaseItems(TestFactory.GetPhysicalProducts()));

            // Act
            await rulesProcessor.ProcessOrderAsync(purchaseOrder);

            // Assert
            mockCustomerService.Verify(x => x.ActivateMembershipAsync(It.IsAny <int>(), It.IsAny <int>()), Times.Never);
        }
Exemplo n.º 2
0
        public async Task MembershipActivationRule_MembershipsAreActivated()
        {
            // Arrange
            Mock <ICustomerService> mockCustomerService = TestFactory.CreateMockCustomerService();
            IRule          membershipActivationRule     = TestFactory.CreateMembershipActivationRule(mockCustomerService.Object);
            RulesProcessor rulesProcessor = new RulesProcessor(new List <IRule>()
            {
                membershipActivationRule
            });
            PurchaseOrder purchaseOrder = TestFactory.GetPurchaseOrder();

            // Act
            await rulesProcessor.ProcessOrderAsync(purchaseOrder);

            // Assert
            foreach (PurchaseItem item in purchaseOrder.Items.Where(x => x.Product is MembershipProduct))
            {
                mockCustomerService.Verify(x => x.ActivateMembershipAsync(purchaseOrder.CustomerId, item.Product.Id));
            }
        }