Beispiel #1
0
        public void Should_Add_SetOptional_When_SetOptional_ReferenceType()
        {
            var builderInterface = new MemberSpecificationBuilder <object, MemberClass>() as
                                   IMemberSpecificationBuilder <object, MemberClass>;

            builderInterface.SetOptional();

            var builder = (MemberSpecificationBuilder <object, MemberClass>)builderInterface;

            Assert.Single(builder.Commands);
            Assert.IsType <SetOptionalCommand>(builder.Commands.Single());
        }
Beispiel #2
0
            public void Should_Add_SetOptionalCommand_When_SetOptional()
            {
                var builder = new MemberSpecificationBuilder <object, object>();

                builder.SetOptional();

                Assert.Single(builder.Commands);
                Assert.IsType <SetOptionalCommand>(builder.Commands.Single());

                var command = (SetOptionalCommand)builder.Commands.Single();

                Assert.Equal("SetOptional", command.Name);
            }
Beispiel #3
0
        public void Should_AddMultipleCommands()
        {
            var builder = new MemberSpecificationBuilder <object, MemberClass>();

            builder
            .SetOptional()
            .SetRequired("required")
            .Valid(x => false)
            .WithMessage("message")
            .AsRelative(x => true)
            .AsModel();

            Assert.Equal(6, builder.Commands.Count);
            Assert.IsType <SetOptionalCommand>(builder.Commands.ElementAt(0));
            Assert.IsType <SetRequiredCommand>(builder.Commands.ElementAt(1));
            Assert.IsType <ValidRule <MemberClass> >(builder.Commands.ElementAt(2));
            Assert.IsType <WithMessageCommand>(builder.Commands.ElementAt(3));
            Assert.IsType <AsRelativeRule <object> >(builder.Commands.ElementAt(4));
            Assert.IsType <AsModelRule <MemberClass> >(builder.Commands.ElementAt(5));
        }