コード例 #1
0
        public IProduct OrderCreation(string product)
        {
            IProduct InitiateProduct = null;

            switch (product)
            {
            case "Book":

                InitiateProduct = new Book();
                break;

            case "PhysicalProduct":

                InitiateProduct = new PhysicalProduct();
                break;

            case "NewMembership":

                InitiateProduct = new NewMembership();
                break;

            case "Upgrade":

                InitiateProduct = new UpgradeMembership();
                break;

            case "Video":

                InitiateProduct = new Video();
                break;
            }

            return(InitiateProduct);
        }
コード例 #2
0
        public void Test_UpgradeMembershipWithIEmailService()
        {
            IEmailService iEmailService = new UpgradeMembership();
            bool          res           = iEmailService.SendMail();

            Assert.AreEqual(res, true);
        }
コード例 #3
0
        public void Test_UpgradeToMembership()
        {
            IUpgrade iUpgrade = new UpgradeMembership();
            bool     res      = iUpgrade.Upgrade();

            Assert.AreEqual(res, true);
        }
コード例 #4
0
        public void RuleNotMatch()
        {
            var phyproduct = new UpgradeMembership();
            var result     = phyproduct.Handle("Failure");

            // Assert
            Assert.AreNotEqual("Apply the upgrade\n", result);
        }
コード例 #5
0
        public void ValidateRules()
        {
            var upmembership = new UpgradeMembership();
            var result       = upmembership.Handle("upgrade");

            // Assert
            Assert.AreEqual("Apply the upgrade\n", result);
        }
コード例 #6
0
        public void upgradeMembershipNoException()
        {
            //Arrange
            IOrder order = new UpgradeMembership();
            int    result;

            //Assert
            Assert.DoesNotThrow(() => order.ActionTaken(out result));
        }
コード例 #7
0
        public void upgradeMembershipFailureTest()
        {
            // upgradeMembership
            IOrder order = new UpgradeMembership();
            int    result;

            //Act
            order.ActionTaken(out result);

            //Assert
            Assert.AreEqual(1, result);
        }
コード例 #8
0
        public void upgradeMembershipSuccessTest()
        {
            //Arrange
            IOrder order = new UpgradeMembership();
            int    result;

            //Act
            order.ActionTaken(out result);

            //Assert
            Assert.AreEqual(1, result);
        }
コード例 #9
0
        public void Setup()
        {
            _membershipUpgrade = new Product(new ProductConfig {
                Id = "Expected Membership Id"
            });

            _mockOrder = new Mock <Order>();
            _mockOrder.SetupGet(m => m.Product).Returns(_membershipUpgrade);

            _mockServiceBus    = new Mock <IServiceBus>();
            _upgradeMembership = new UpgradeMembership(_mockServiceBus.Object);
        }
コード例 #10
0
ファイル: DemoPaymentTest.cs プロジェクト: prrkumar/demo1
        public void TestForUpgradeMembership()
        {
            //arrange
            string expectedresult = "Upgrade Membership!";

            IProduct product = new UpgradeMembership();

            // act
            var rtntext = product.ProcessPayment();

            // assert
            Assert.Equal(expectedresult, rtntext);
        }
コード例 #11
0
        /// <summary>
        /// Pass the request to handler according to Payment Type
        /// </summary>
        private static void RuleHandler()
        {
            AbstractHandler abstractHandler = null;
            var             email           = new SendEmail();
            var             compayment      = new CommissionPayment();

            var ctx = new Context()
            {
                PaymentType = ReadInputRequest()
            };
            var handler = ctx.PaymentType;

            switch (handler)
            {
            case "PhysicalProduct":
                abstractHandler = new PhysicalProduct();
                abstractHandler.SetNext(compayment);
                break;

            case "ProductBook":
                abstractHandler = new ProdcutBook();
                abstractHandler.SetNext(compayment);
                break;

            case "Membership":
                abstractHandler = new Membership();
                abstractHandler.SetNext(email);
                break;

            case "UpgradeMembership":
                abstractHandler = new UpgradeMembership();
                abstractHandler.SetNext(email);
                break;

            case "Video":
                abstractHandler = new Video();
                break;

            default:
                break;
            }

            RuleEngOrchestrator.ClientCode(abstractHandler);
            Console.WriteLine();
        }
コード例 #12
0
        public Response RunBusinessRuleEngine(PaymentType type)
        {
            switch (type)
            {
            case PaymentType.PHYSICAL_PRODUCT:
            {
                var createCommissionPayment = new ProcessCommissionPayment();
                var packingSlip             = new PhysicalProductPackingSlip(createCommissionPayment);
                return(packingSlip.Process());
            }

            case PaymentType.BOOK:
            {
                var createCommissionPayment = new ProcessCommissionPayment();
                var GeneratePackingSlipForRoyaltyDepartment = new CreateDuplicateSlipForRoyaldepartment(createCommissionPayment);
                return(GeneratePackingSlipForRoyaltyDepartment.Process());
            }

            case PaymentType.MEMBERSHIP_ACTIVATE:
            {
                var sendEmailNotifification = new NotifyEmail();
                var activateMemberShip      = new ActivateMemeberShip(sendEmailNotifification);
                return(activateMemberShip.Process());
            }

            case PaymentType.MEMBERSHIP_UPGRADE:
            {
                var sendEmailNotifification = new NotifyEmail();
                var applyUpgrade            = new UpgradeMembership(sendEmailNotifification);
                return(applyUpgrade.Process());
            }

            case PaymentType.VIDEO:
            {
                var addFirstAidVideo = new AddFirstAidVideo();
                var packingSlip      = new PhysicalProductPackingSlip(addFirstAidVideo);
                return(packingSlip.Process());
            }

            default:
                return(new Response((int)Status.FAIL, "payment type is not found"));
            }
        }
コード例 #13
0
        public void Setup()
        {
            var membership = new Product(new ProductConfig
            {
                Type    = "Membership",
                SubType = "Upgrade"
            });

            _upgradeMembershipOrder = new Order(new OrderConfig {
                Id = "Test Upgrade Membership Order"
            });
            _upgradeMembershipOrder.SetProduct(membership);

            _anyOtherOrder = new Order(new OrderConfig {
                Id = "Anything"
            });
            _anyOtherOrder.SetProduct(new Product(new ProductConfig {
                Type = "Anything"
            }));

            _upgradeMembership = new UpgradeMembership(new Mock <IServiceBus>().Object);
        }