コード例 #1
0
        public void Can_Create_Multiple_Eligible_Object()
        {
            // Arrange
            _paramListBuilder.WithMultipleEligibility(1);
            ActivatorProductParamToEligibilityMapper target = new ActivatorProductParamToEligibilityMapper();

            // Act
            IList <IEligibility>      result          = target.MapParamsToEligibility(_paramListBuilder.Build());
            FormSubtypeEligibility    formSubtype1    = result[0] as FormSubtypeEligibility;
            SubscriberTypeEligibility subscriberType1 = result[1] as SubscriberTypeEligibility;
            TariffsEligibility        tariffs1        = result[2] as TariffsEligibility;
            FormSubtypeEligibility    formSubtype2    = result[3] as FormSubtypeEligibility;
            SubscriberTypeEligibility subscriberType2 = result[4] as SubscriberTypeEligibility;
            MultipleItemsEligibility  multipleItems1  = result[5] as MultipleItemsEligibility;
            TariffsEligibility        tariffs2        = result[6] as TariffsEligibility;

            // Assert - FormSubtypeEligibility in rule set 1
            Assert.IsNotNull(formSubtype1);
            Assert.IsTrue(formSubtype1.RuleSet == 1);
            Assert.IsTrue(formSubtype1.ValidSubtypes == "1,5,7");
            // Assert - SubscriberTypeEligibility in rule set 1
            Assert.IsNotNull(subscriberType1);
            Assert.IsTrue(subscriberType1.RuleSet == 1);
            Assert.IsTrue(subscriberType1.SubscriberType == "1,2,3");
            // Assert - TariffsEligibility in rule set 1
            Assert.IsNotNull(tariffs1);
            Assert.IsTrue(tariffs1.RuleSet == 1);
            Assert.IsTrue(tariffs1.AllowedTariffs == "14,27,61");
            // Assert - FormSubtypeEligibility in rule set 2
            Assert.IsNotNull(formSubtype2);
            Assert.IsTrue(formSubtype2.RuleSet == 2);
            Assert.IsTrue(formSubtype2.ValidSubtypes == "1");
            // Assert - SubscriberTypeEligibility in rule set 2
            Assert.IsNotNull(subscriberType2);
            Assert.IsTrue(subscriberType2.RuleSet == 2);
            Assert.IsTrue(subscriberType2.SubscriberType == "2");
            // Assert - MultipleItemsEligibility in rule set 3
            Assert.IsNotNull(multipleItems1);
            Assert.IsTrue(multipleItems1.RuleSet == 3);
            Assert.IsTrue(multipleItems1.MinCount == "2");
            Assert.IsTrue(multipleItems1.MaxCount == "5");
            // Assert - TariffsEligibility in rule set 3
            Assert.IsNotNull(tariffs2);
            Assert.IsTrue(tariffs2.RuleSet == 3);
            Assert.IsTrue(tariffs2.AllowedTariffs == "61");
        }
コード例 #2
0
        public void Can_Create_A_Composite_With_Multiple_Rule_Set_With_Multiple_Eligibility()
        {
            // Arrange
            _targetBuilder.WithMultipleRuleSetWithMultipleEligibility(1);
            CompositeEligibilityFactory target = _targetBuilder.Build();

            // Act
            IEligibility result = target.Create(1);
            // Retrieve first rule set.
            RuleSet1Eligibility       ruleSetOne      = result as RuleSet1Eligibility;
            FormSubtypeEligibility    formSubtype1    = ruleSetOne.Components[0] as FormSubtypeEligibility;
            SubscriberTypeEligibility subscriberType1 = ruleSetOne.Components[1] as SubscriberTypeEligibility;
            TariffsEligibility        tariffs1        = ruleSetOne.Components[2] as TariffsEligibility;

            // Retrieve second rule set.
            RuleSetOtherEligibility   ruleSetTwo      = ruleSetOne.Components[3] as RuleSetOtherEligibility;
            FormSubtypeEligibility    formSubtype2    = ruleSetTwo.Components[0] as FormSubtypeEligibility;
            SubscriberTypeEligibility subscriberType2 = ruleSetTwo.Components[1] as SubscriberTypeEligibility;

            // Retrieve third rule set.
            RuleSetOtherEligibility   ruleSetThree    = ruleSetTwo.Components[2] as RuleSetOtherEligibility;
            SubscriberTypeEligibility subscriberType3 = ruleSetThree.Components[0] as SubscriberTypeEligibility;
            TariffsEligibility        tariffs2        = ruleSetThree.Components[1] as TariffsEligibility;

            // Retrieve fourth rule set.
            RuleSetOtherEligibility   ruleSetFour     = ruleSetThree.Components[2] as RuleSetOtherEligibility;
            SubscriberTypeEligibility subscriberType4 = ruleSetFour.Components[0] as SubscriberTypeEligibility;
            TariffsEligibility        tariffs3        = ruleSetFour.Components[1] as TariffsEligibility;

            // Assert - RuleSet1Eligibility representing Rule set 1
            Assert.IsNotNull(ruleSetOne);
            Assert.IsTrue(ruleSetOne.RuleSet == 1);
            Assert.IsTrue(ruleSetOne.Components.Count == 4);
            // Assert - FormSubtypeEligibility in Rule set 1
            Assert.IsNotNull(formSubtype1);
            Assert.IsTrue(formSubtype1.RuleSet == 1);
            Assert.IsTrue(formSubtype1.ValidSubtypes == "1,5,7");
            // Assert - SubscriberTypeEligibility in Rule set 1
            Assert.IsNotNull(subscriberType1);
            Assert.IsTrue(subscriberType1.RuleSet == 1);
            Assert.IsTrue(subscriberType1.SubscriberType == "1,2,3");
            // Assert - TariffsEligibility in Rule set 1
            Assert.IsNotNull(tariffs1);
            Assert.IsTrue(tariffs1.RuleSet == 1);
            Assert.IsTrue(tariffs1.AllowedTariffs == "14,27,61");
            // Assert - RuleSetOtherEligibility representing Rule set 2
            Assert.IsNotNull(ruleSetTwo);
            Assert.IsTrue(ruleSetTwo.RuleSet == 2);
            // Assert - FormSubtypeEligibility in Rule set 2
            Assert.IsNotNull(formSubtype2);
            Assert.IsTrue(formSubtype2.RuleSet == 2);
            Assert.IsTrue(formSubtype2.ValidSubtypes == "1");
            // Assert - SubscriberTypeEligibility in Rule set 2
            Assert.IsNotNull(subscriberType2);
            Assert.IsTrue(subscriberType2.RuleSet == 2);
            Assert.IsTrue(subscriberType2.SubscriberType == "2");
            // Assert - RuleSetOtherEligibility representing Rule set 3
            Assert.IsNotNull(ruleSetThree);
            Assert.IsTrue(ruleSetThree.RuleSet == 3);
            // Assert - SubscriberTypeEligibility in Rule set 3
            Assert.IsNotNull(subscriberType3);
            Assert.IsTrue(subscriberType3.RuleSet == 3);
            Assert.IsTrue(subscriberType3.SubscriberType == "3");
            // Assert - TariffsEligibility in Rule set 3
            Assert.IsNotNull(tariffs2);
            Assert.IsTrue(tariffs2.RuleSet == 3);
            Assert.IsTrue(tariffs2.AllowedTariffs == "61");
            // Assert - RuleSetOtherEligibility representing Rule set 4
            Assert.IsNotNull(ruleSetFour);
            Assert.IsTrue(ruleSetFour.RuleSet == 4);
            // Assert - SubscriberTypeEligibility in Rule set 4
            Assert.IsNotNull(subscriberType4);
            Assert.IsTrue(subscriberType4.RuleSet == 4);
            Assert.IsTrue(subscriberType4.SubscriberType == "1");
            // Assert - TariffsEligibility in Rule set 4
            Assert.IsNotNull(tariffs3);
            Assert.IsTrue(tariffs3.RuleSet == 4);
            Assert.IsTrue(tariffs3.AllowedTariffs == "14");
        }