public void Should_BeEntryPoint()
 {
     ApiTester.TestOutputPossibilities <IAndOut <object> >(new[]
     {
         typeof(IRuleIn <object>)
     });
 }
Beispiel #2
0
 public void Should_BeEntryPoint()
 {
     ApiTester.TestOutputPossibilities <IOptionalOut <object> >(new[]
     {
         typeof(ISpecificationOut <object>),
         typeof(IRuleIn <object>)
     });
 }
Beispiel #3
0
 public void Should_ForbiddenWithExtraCode_BeEntryPoint()
 {
     ApiTester.TestOutputPossibilities <IWithExtraCodeForbiddenOut <object> >(new[]
     {
         typeof(ISpecificationOut <object>),
         typeof(IWithExtraCodeForbiddenIn <object>)
     });
 }
Beispiel #4
0
 public void Should_ForbiddenWithMessage_ThrowException_When_NullMessage()
 {
     ApiTester.TextException <object, IWithMessageForbiddenIn <object>, IWithMessageForbiddenOut <object> >(
         s => s.WithMessage(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
 public void Should_ThrowException_When_NullExecutionCondition()
 {
     ApiTester.TextException <object, IWithConditionIn <object>, IWithConditionOut <object> >(
         s => s.WithCondition(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
Beispiel #6
0
 public void Should_Add_WithPathCommand()
 {
     ApiTester.TestSingleCommand <object, IWithPathIn <object>, IWithPathOut <object>, WithPathCommand>(
         s => s.WithPath("path"),
         command =>
     {
         command.Path.Should().Be("path");
     });
 }
Beispiel #7
0
 public void Should_ThrowException_When_NullName()
 {
     ApiTester.TextException <object, IWithPathIn <object>, IWithPathOut <object> >(
         s => s.WithPath(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
Beispiel #8
0
 public void Should_Rule_ThrowException_When_NullPredicate()
 {
     ApiTester.TextException <object, IRuleIn <object>, IRuleIn <object> >(
         s => s.Rule(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
Beispiel #9
0
 public void Should_Accept_ValidPaths(string path)
 {
     ApiTester.TestSingleCommand <object, IWithPathIn <object>, IWithPathOut <object>, WithPathCommand>(
         s => s.WithPath(path),
         command =>
     {
         command.Path.Should().Be(path);
     });
 }
Beispiel #10
0
 public void Should_ReturnFalse_For_InvalidPaths(string path)
 {
     ApiTester.TextException <object, IWithPathIn <object>, IWithPathOut <object> >(
         s => s.WithPath(path),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentException>().WithMessage("Invalid path*");
     });
 }
Beispiel #11
0
 public void Should_WithExtraCode_ThrowException_When_NullMessage()
 {
     ApiTester.TextException <object, IWithExtraCodeIn <object>, IWithExtraCodeOut <object> >(
         s => s.WithExtraCode(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
Beispiel #12
0
 public void Should_Accept_ValidCodes(string code)
 {
     ApiTester.TestSingleCommand <object, IWithExtraCodeIn <object>, IWithExtraCodeOut <object>, WithExtraCodeCommand>(
         s => s.WithExtraCode(code),
         command =>
     {
         command.Code.Should().Be(code);
     });
 }
Beispiel #13
0
 public void Should_ThrowException_When_InvalidCodes(string code)
 {
     ApiTester.TextException <object, IWithExtraCodeIn <object>, IWithExtraCodeOut <object> >(
         s => s.WithExtraCode(code),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentException>().WithMessage("Invalid code*");
     });
 }
 public void Should_ThrowException_When_NullSpecification()
 {
     ApiTester.TextException <ICollection <object>, IRuleIn <ICollection <object> >, IRuleOut <ICollection <object> > >(
         s => s.AsCollection(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
 public void Should_ThrowException_When_NullModelSpecification()
 {
     ApiTester.TextException <int?, IRuleIn <int?>, IRuleOut <int?> >(
         s => s.AsNullable(null),
         addingAction =>
     {
         addingAction.Should().ThrowExactly <ArgumentNullException>();
     });
 }
Beispiel #16
0
 public void Should_WithMessage_Add_WithMessageCommand()
 {
     ApiTester.TestSingleCommand <object, IWithMessageIn <object>, IWithMessageOut <object>, WithMessageCommand>(
         s => s.WithMessage("message"),
         command =>
     {
         command.Message.Should().NotBeNull();
         command.Message.Should().Be("message");
     });
 }
Beispiel #17
0
 public void Should_WithExtraCode_BeEntryPoint()
 {
     ApiTester.TestOutputPossibilities <IWithExtraCodeOut <object> >(new[]
     {
         typeof(ISpecificationOut <object>),
         typeof(IRuleIn <object>),
         typeof(IWithExtraCodeIn <object>),
         typeof(IAndIn <object>)
     });
 }
Beispiel #18
0
 public void Should_WithExtraCode_Add_WithExtraCodeCommand()
 {
     ApiTester.TestSingleCommand <object, IWithExtraCodeIn <object>, IWithExtraCodeOut <object>, WithExtraCodeCommand>(
         s => s.WithExtraCode("code"),
         command =>
     {
         command.Code.Should().NotBeNull();
         command.Code.Should().Be("code");
     });
 }
Beispiel #19
0
        public void Should_ThrowException_When_NullMemberSelector()
        {
            Specification <string> memberSpecification = s => s;

            ApiTester.TextException <TestClass, IRuleIn <TestClass>, IRuleOut <TestClass> >(
                s => s.Member(null, memberSpecification),
                addingAction =>
            {
                addingAction.Should().ThrowExactly <ArgumentNullException>();
            });
        }
Beispiel #20
0
        public void Should_ThrowException_When_NullMemberSpecification()
        {
            Expression <Func <TestClass, string> > memberSelector = m => m.TestProperty;

            ApiTester.TextException <TestClass, IRuleIn <TestClass>, IRuleOut <TestClass> >(
                s => s.Member(memberSelector, null),
                addingAction =>
            {
                addingAction.Should().ThrowExactly <ArgumentNullException>();
            });
        }
            public void Should_Add_AsCollectionCommand()
            {
                Specification <object> specification = s => s;

                ApiTester.TestSingleCommand <ICollection <object>, IRuleIn <ICollection <object> >, IRuleOut <ICollection <object> >, AsCollectionCommand <ICollection <object>, object> >(
                    s => s.AsCollection(specification),
                    command =>
                {
                    command.Specification.Should().NotBeNull();
                    command.Specification.Should().BeSameAs(specification);
                });
            }
        public void Should_Add_AsNullableCommand()
        {
            Specification <int> modelSpecification = s => s;

            ApiTester.TestSingleCommand <int?, IRuleIn <int?>, IRuleOut <int?>, AsNullableCommand <int> >(
                s => s.AsNullable(modelSpecification),
                command =>
            {
                command.Specification.Should().NotBeNull();
                command.Specification.Should().BeSameAs(modelSpecification);
            });
        }
Beispiel #23
0
        public void Should_Add_AsModelCommand()
        {
            Specification <object> modelSpecification = s => s;

            ApiTester.TestSingleCommand <object, IRuleIn <object>, IRuleOut <object>, AsModelCommand <object> >(
                s => s.AsModel(modelSpecification),
                command =>
            {
                command.Specification.Should().NotBeNull();
                command.Specification.Should().BeSameAs(modelSpecification);
            });
        }
        public void Should_Add_WithConditionCommand()
        {
            Predicate <object> predicate = x => true;

            ApiTester.TestSingleCommand <object, IWithConditionIn <object>, IWithConditionOut <object>, WithConditionCommand <object> >(
                s => s.WithCondition(predicate),
                command =>
            {
                command.ExecutionCondition.Should().NotBeNull();
                command.ExecutionCondition.Should().BeSameAs(predicate);
            });
        }
Beispiel #25
0
 public void Should_BeEntryPoint()
 {
     ApiTester.TestOutputPossibilities <IWithPathOut <object> >(new[]
     {
         typeof(ISpecificationOut <object>),
         typeof(IRuleIn <object>),
         typeof(IWithMessageIn <object>),
         typeof(IWithExtraMessageIn <object>),
         typeof(IWithCodeIn <object>),
         typeof(IWithExtraCodeIn <object>),
     });
 }
Beispiel #26
0
        public void Should_Rule_Add_Command()
        {
            Predicate <object> predicate = x => true;

            ApiTester.TestSingleCommand <object, IRuleIn <object>, IRuleIn <object>, RuleCommand <object> >(
                s => s.Rule(predicate),
                command =>
            {
                command.Args.Should().BeNull();
                command.Message.Should().BeNull();
                command.Predicate.Should().BeSameAs(predicate);
            });
        }
Beispiel #27
0
        public void Should_RuleTemplate_Add_Command_WithoutArgs()
        {
            Predicate <object> predicate = x => true;

            ApiTester.TestSingleCommand <object, IRuleIn <object>, IRuleIn <object>, RuleCommand <object> >(
                s => s.RuleTemplate(predicate, "messageKey", null),
                command =>
            {
                command.Args.Should().BeNull();

                command.Message.Should().Be("messageKey");

                command.Predicate.Should().BeSameAs(predicate);
            });
        }
Beispiel #28
0
        public void Should_Add_MemberCommand()
        {
            Specification <string> memberSpecification            = s => s;
            Expression <Func <TestClass, string> > memberSelector = m => m.TestProperty;

            ApiTester.TestSingleCommand <TestClass, IRuleIn <TestClass>, IRuleOut <TestClass>, MemberCommand <TestClass, string> >(
                s => s.Member(memberSelector, memberSpecification),
                command =>
            {
                command.Specification.Should().NotBeNull();
                command.Specification.Should().BeSameAs(memberSpecification);

                command.MemberSelector.Should().NotBeNull();
                command.MemberSelector.Should().BeSameAs(memberSelector);
            });
        }
Beispiel #29
0
        public void Should_RuleTemplate_ThrowException_When_NullPredicate()
        {
            var args = new[]
            {
                Arg.Text("1", "1"),
                Arg.Number("2", 2),
                Arg.Type("3", typeof(Guid))
            };

            ApiTester.TextException <object, IRuleIn <object>, IRuleIn <object> >(
                s => s.RuleTemplate(null, "message", args),
                addingAction =>
            {
                addingAction.Should().ThrowExactly <ArgumentNullException>();
            });
        }
Beispiel #30
0
        public void Should_RuleTemplate_ThrowException_When_NullInArgs()
        {
            Predicate <object> predicate = x => true;

            var args = new[]
            {
                Arg.Text("1", "1"),
                null,
                Arg.Type("3", typeof(Guid))
            };

            ApiTester.TextException <object, IRuleIn <object>, IRuleIn <object> >(
                s => s.RuleTemplate(predicate, "message", args),
                addingAction =>
            {
                addingAction.Should().ThrowExactly <ArgumentNullException>();
            });
        }