public void GetManifestRuleShouldReturnAManifestRuleWithCorrectDependencies([Frozen] IGetsManifestRuleIdentifierFromRelativeIdentifier relativeToManifestIdentityConverter, [Frozen] IGetsManifestRuleIdentifier identifierFactory, [Frozen, ManifestModel] ValidatorBuilderContext context, RuleBuilder <SampleRule> sut, [ManifestModel] ManifestRuleIdentifier identifier, RelativeRuleIdentifier relativeId1, RelativeRuleIdentifier relativeId2, RelativeRuleIdentifier relativeId3, [ManifestModel] ManifestRuleIdentifier manifestId1, [ManifestModel] ManifestRuleIdentifier manifestId2, [ManifestModel] ManifestRuleIdentifier manifestId3) { Mock.Get(identifierFactory) .Setup(x => x.GetManifestRuleIdentifier(typeof(SampleRule), It.IsAny <ValidatorBuilderContext>(), It.IsAny <string>())) .Returns(identifier); Mock.Get(relativeToManifestIdentityConverter).Setup(x => x.GetManifestRuleIdentifier(context.ManifestValue, relativeId1)).Returns(manifestId1); Mock.Get(relativeToManifestIdentityConverter).Setup(x => x.GetManifestRuleIdentifier(context.ManifestValue, relativeId2)).Returns(manifestId2); Mock.Get(relativeToManifestIdentityConverter).Setup(x => x.GetManifestRuleIdentifier(context.ManifestValue, relativeId3)).Returns(manifestId3); sut.Dependencies = new[] { relativeId1, relativeId2, relativeId3 }; var result = sut.GetManifestValue().Rules.Single(); Assert.That(result, Has.Property(nameof(ManifestRule.DependencyRules)).EquivalentTo(new[] { manifestId1, manifestId2, manifestId3 })); }
public void GetManifestRuleShouldReturnAManifestRuleWithCorrectConfigurationAction([Frozen] IGetsManifestRuleIdentifier identifierFactory, [Frozen, ManifestModel] ValidatorBuilderContext context, RuleBuilder <SampleRule> sut, [ManifestModel] ManifestRuleIdentifier identifier, string stringPropValue) { Mock.Get(identifierFactory) .Setup(x => x.GetManifestRuleIdentifier(typeof(SampleRule), It.IsAny <ValidatorBuilderContext>(), It.IsAny <string>())) .Returns(identifier); sut.ConfigureRule(r => r.StringProp = stringPropValue); sut.Dependencies.Clear(); var rule = sut.GetManifestValue().Rules.Single(); var sampleRule = new SampleRule(); rule.RuleConfiguration(sampleRule); Assert.That(sampleRule.StringProp, Is.EqualTo(stringPropValue), "Configuration action applied correctly"); }
public void GetManifestRuleShouldReturnAManifestRulewithCorrectIdentifierFromService([Frozen, ManifestModel] ValidatorBuilderContext context, [Frozen] IGetsManifestRuleIdentifier identifierFactory, RuleBuilder <SampleRule> sut, [ManifestModel] ManifestRuleIdentifier identifier) { Mock.Get(identifierFactory) .Setup(x => x.GetManifestRuleIdentifier(typeof(SampleRule), It.IsAny <ValidatorBuilderContext>(), It.IsAny <string>())) .Returns(identifier); Func <object, object> GetFunc(Func <object, object> input) => input; context.ManifestValue.IdentityAccessor = GetFunc(x => new object()); sut.Dependencies.Clear(); sut.Name = "Rule name"; var rule = sut.GetManifestValue().Rules.Single(); Assert.That(rule.Identifier, Is.SameAs(identifier)); }