public void Can_Create_A_Composite_With_Single_Rule_Set_With_Multiple_Eligibility() { // Arrange int productId = 1; _targetBuilder.WithSingleRuleSetWithMultipleEligibility(productId); CompositeEligibilityFactory target = _targetBuilder.Build(); // Act RuleSet1Eligibility ruleSet1result = target.Create(productId) as RuleSet1Eligibility; MultipleItemsEligibility multipleResult = ruleSet1result.Components[0] as MultipleItemsEligibility; FormSubtypeEligibility formSubtypeResult = ruleSet1result.Components[1] as FormSubtypeEligibility; // Assert - MultipleItemsEligibility Assert.IsNotNull(multipleResult); Assert.IsTrue(multipleResult.RuleSet == 1); Assert.IsTrue(multipleResult.MinCount == "1"); Assert.IsTrue(multipleResult.MaxCount == "4"); // Assert - FormSubtypeEligibility Assert.IsNotNull(formSubtypeResult); Assert.IsTrue(formSubtypeResult.RuleSet == 1); Assert.IsTrue(formSubtypeResult.ValidSubtypes == "1,5,7"); // Assert - Verify mocked method was called exactly once. _targetBuilder._mockMapper.Verify(m => m.MapParamsToEligibility(It.IsAny <IList <ProductEligibilityParam> >()), Times.Once); }
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"); }
public void Can_Create_A_Single_Eligible_Object_With_Single_Property() { // Arrange int productId = 1; _paramListBuilder.WithSingleEligibilityWithSingleProperty(productId); ActivatorProductParamToEligibilityMapper target = new ActivatorProductParamToEligibilityMapper(); // Act IList <IEligibility> result = target.MapParamsToEligibility(_paramListBuilder.Build()); FormSubtypeEligibility formSubtype = result[0] as FormSubtypeEligibility; // Assert Assert.IsNotNull(formSubtype); Assert.IsTrue(formSubtype.RuleSet == 1); Assert.IsTrue(formSubtype.ValidSubtypes == "1,5,7"); }
public void Can_Create_A_Composite_With_Single_Rule_Set_With_Single_Eligibility() { // Arrange int productId = 1; _targetBuilder.WithSingleRuleSetWithSingleEligibility(productId); CompositeEligibilityFactory target = _targetBuilder.Build(); // Act RuleSet1Eligibility ruleSetResult = target.Create(productId) as RuleSet1Eligibility; FormSubtypeEligibility result = ruleSetResult.Components[0] as FormSubtypeEligibility; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.RuleSet == 1); Assert.IsTrue(result.ValidSubtypes == "1,5,7"); _targetBuilder._mockMapper.Verify(m => m.MapParamsToEligibility(It.IsAny <IList <ProductEligibilityParam> >()), Times.Once); }
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"); }