public void Validate_OneOfWithIComparer_Correctly(int value, bool expected)
        {
            // Arrange
            var values    = new[] { new TestClass(1), new TestClass(2), new TestClass(3) };
            var validator = new OneOfValidator <TestClass>(values, new TestComparer());

            // Act
            bool isValid = validator.IsValid(new TestClass(value));

            // Assert
            Assert.Equal(expected, isValid);
        }
        public void Validate_OneOf_Correcly(int value, bool expected)
        {
            //Arrange
            int[] values = new[] { 1, 2, 3, 4, 5 };
            IValueValidator <int> oneOfValidator = new OneOfValidator <int>(values);

            //Act
            bool valid = oneOfValidator.IsValid(value);

            //Assert
            Assert.Equal(expected, valid);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Specifies the values that make up the set the target must belong to.
 /// </summary>
 /// <param name="values">The values.</param>
 /// <exception cref="ArgumentNullException">Thrown if values is null.</exception>
 public OneOfAttribute(params object[] values)
 {
     _values    = values;
     _validator = new OneOfValidator <object>(values);
 }