Ejemplo n.º 1
0
            public void Should_ThrowException_When_Valid_WithMessageAndArgs_And_NullPredicate()
            {
                var builder = new MemberSpecificationBuilder <object, int>();

                var args = new[] { Arg.Text("n", "v") };

                Assert.Throws <ArgumentNullException>(() => { builder.Valid(null, "message", args); });
            }
Ejemplo n.º 2
0
            public void Should_ThrowException_When_Valid_And_ArgsWithoutMessage()
            {
                var builder = new MemberSpecificationBuilder <object, int>();

                Predicate <int> isValid = c => true;
                var             args    = new[] { Arg.Text("n", "v") };

                Assert.Throws <ArgumentNullException>(() => { builder.Valid(isValid, null, args); });
            }
Ejemplo n.º 3
0
            public void Should_Add_ValidRule_When_Valid()
            {
                var builder = new MemberSpecificationBuilder <object, int>();

                Predicate <int> isValid = c => true;

                builder.Valid(isValid);

                Assert.Single(builder.Commands);
                Assert.IsType <ValidRule <int> >(builder.Commands.Single());

                var command = (ValidRule <int>)builder.Commands.Single();

                Assert.Equal("Valid", command.Name);
                Assert.Null(command.RuleSingleError);
                Assert.Null(command.Error);
                Assert.Same(isValid, command.IsValid);
            }
Ejemplo n.º 4
0
            public void Should_Add_ValidRule_When_Valid_With_MessageAndArgs()
            {
                var builder = new MemberSpecificationBuilder <object, int>();

                Predicate <int> isValid = c => true;
                var             args    = new[] { Arg.Text("n", "v") };

                builder.Valid(isValid, "message", args);

                Assert.Single(builder.Commands);
                Assert.IsType <ValidRule <int> >(builder.Commands.Single());

                var command = (ValidRule <int>)builder.Commands.Single();

                Assert.Equal("Valid", command.Name);
                Assert.Null(command.RuleSingleError);
                Assert.NotNull(command.Error);
                Assert.Equal("message", command.Error.Message);
                Assert.Same(args, command.Error.Arguments);
                Assert.Same(isValid, command.IsValid);
            }
Ejemplo n.º 5
0
            public void Should_ThrowException_When_Valid_And_NullPredicate()
            {
                var builder = new MemberSpecificationBuilder <object, int>();

                Assert.Throws <ArgumentNullException>(() => { builder.Valid(null); });
            }