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_Multiple_Properties() { // Arrange int productId = 1; _paramListBuilder.WithSingleEligibilityWithMultipleProperties(productId); ActivatorProductParamToEligibilityMapper target = new ActivatorProductParamToEligibilityMapper(); // Act MultipleItemsEligibility result = target.MapParamsToEligibility(_paramListBuilder.Build())[0] as MultipleItemsEligibility; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.RuleSet == 1); Assert.IsTrue(result.MinCount == "1"); Assert.IsTrue(result.MaxCount == "4"); }