Exemple #1
0
        public void Flags_enum_valid_when_using_bitwise_value()
        {
            var inlineValidator = Create_validator();
            var poco            = new FlagsEnumPoco();

            poco.PopulateWithValidValues();

            var result = inlineValidator.Validate(poco);

            result.IsValid.ShouldBeTrue();

            // special case - valid negative value
            poco.EnumWithNegativesValue = EnumWithNegatives.All;
            result = inlineValidator.Validate(poco);
            result.IsValid.ShouldBeTrue();
        }
        public void Flags_enum_valid_when_using_bitwise_value()
        {
            var inlineValidator = new InlineValidator <FlagsEnumPoco>();

            inlineValidator.RuleFor(x => x.SByteValue).IsInEnum();
            inlineValidator.RuleFor(x => x.ByteValue).IsInEnum();
            inlineValidator.RuleFor(x => x.Int16Value).IsInEnum();
            inlineValidator.RuleFor(x => x.UInt16Value).IsInEnum();
            inlineValidator.RuleFor(x => x.Int32Value).IsInEnum();
            inlineValidator.RuleFor(x => x.UInt32Value).IsInEnum();
            inlineValidator.RuleFor(x => x.Int64Value).IsInEnum();
            inlineValidator.RuleFor(x => x.UInt64Value).IsInEnum();

            var poco = new FlagsEnumPoco();

            poco.PopulateWithValidValues();

            var result = inlineValidator.Validate(poco);

            result.IsValid.ShouldBeTrue();
        }
        public void Flags_enum_valid_when_using_bitwise_value()
        {
            var inlineValidator = new InlineValidator<FlagsEnumPoco>();
            inlineValidator.RuleFor(x => x.SByteValue).IsInEnum();
            inlineValidator.RuleFor(x => x.ByteValue).IsInEnum();
            inlineValidator.RuleFor(x => x.Int16Value).IsInEnum();
            inlineValidator.RuleFor(x => x.UInt16Value).IsInEnum();
            inlineValidator.RuleFor(x => x.Int32Value).IsInEnum();
            inlineValidator.RuleFor(x => x.UInt32Value).IsInEnum();
            inlineValidator.RuleFor(x => x.Int64Value).IsInEnum();
            inlineValidator.RuleFor(x => x.UInt64Value).IsInEnum();

            var poco = new FlagsEnumPoco();
            poco.PopulateWithValidValues();

            var result = inlineValidator.Validate(poco);
            result.IsValid.ShouldBeTrue();
        }