public void Should_Build_RuleCommandScope_When_RuleTemplate_WithArgs_AndCustomError(string testId, Func <dynamic, ISpecificationOut <TestClass> > appendContentCommands, ErrorContentApiHelper.ExpectedErrorContent expectedErrorContent, Func <dynamic, ISpecificationOut <TestClass> > appendSetupCommands, ErrorSetupApiHelper.ExpectedErrorSetup <TestClass> expectedErrorSetup) { testId.Should().NotBeNull(); var context = new ScopeBuilderContext(); var builder = new ScopeBuilder(); Predicate <TestClass> predicate = x => true; var args = new IArg[] { Arg.Text("argName1", "argValue"), Arg.Number("argName2", 2), }; Specification <TestClass> specification = m => appendSetupCommands(appendContentCommands(m.RuleTemplate(predicate, "ruleKey", args))); var scope = builder.Build(specification, context); scope.CommandScopes.Should().NotBeEmpty(); scope.CommandScopes.Count.Should().Be(1); scope.CommandScopes[0].Should().BeOfType <RuleCommandScope <TestClass> >(); var ruleCommandScope = (RuleCommandScope <TestClass>)scope.CommandScopes[0]; ruleCommandScope.Path.Should().Be(expectedErrorSetup.Path); ruleCommandScope.ExecutionCondition.Should().Be(expectedErrorSetup.ShouldExecute); ruleCommandScope.ErrorMode.Should().Be(expectedErrorContent.Mode); ruleCommandScope.IsValid.Should().BeSameAs(predicate); ruleCommandScope.ErrorId.Should().BeGreaterOrEqualTo(0); if (expectedErrorContent.ShouldBeEmpty()) { ruleCommandScope.ErrorId.Should().Be(context.DefaultErrorId); } else { ruleCommandScope.ErrorId.Should().NotBe(context.DefaultErrorId); context.Errors.Keys.Should().Contain(ruleCommandScope.ErrorId); var error = context.Errors[ruleCommandScope.ErrorId]; expectedErrorContent.Match(error); error.Args.Should().BeSameAs(args); } }