public void When_Object_Is_Null_Then_Valid() { // Arrange var greaterThanAttribute = new GreaterThanAttribute(1); object nullObject = null; // Act var isValid = greaterThanAttribute.IsValid(nullObject); // Assert Assert.IsTrue(isValid); }
public void When_Value_Type_Is_Numeric_And_Greater_Than_Required_Then_Valid(Type type, object value) { // Arrange var greaterThanAttribute = new GreaterThanAttribute(2); var typedValue = Convert.ChangeType(value, type); // Act var isValid = greaterThanAttribute.IsValid(typedValue); // Assert isValid.Should().BeTrue(); }
public void When_Value_Is_Less_Than_Required_Then_Invalid() { // Arrange var greaterThanAttribute = new GreaterThanAttribute(2); var value = 0; // Act var isValid = greaterThanAttribute.IsValid(value); // Assert isValid.Should().BeFalse(); }
public void When_Value_Is_Greater_Than_Required_Value_Then_Valid() { // Arrange var greaterThanAttribute = new GreaterThanAttribute(2); var value = 4; // Act var isValid = greaterThanAttribute.IsValid(value); // Assert isValid.Should().BeTrue(); }
public void When_Value_Type_Is_Not_Numeric_Then_Exception_Is_Thrown() { // Arrange var greaterThanAttribute = new GreaterThanAttribute(10); const string typedValue = "A String"; // Act var exception = Assert.Throws <FormatException>(() => greaterThanAttribute.IsValid(typedValue)); // Assert exception.Should().NotBeNull(); }
public void GreaterThan_EqualZero_FailedValidation() { // Arrange const int arg = 0; // Act var greaterThan = new GreaterThanAttribute(value: arg); var validation = greaterThan.IsValid(value: arg); // Arrange Assert.False(condition: validation); }
public void GreaterThan_GreaterThanZero_SuccessValidation() { // Arrange const int arg = 0; const int arg1 = 1; // Act var greaterThan = new GreaterThanAttribute(value: arg); var validation = greaterThan.IsValid(value: arg1); // Arrange Assert.True(condition: validation); }
public void IsValid_Null() { Assert.True(attribute.IsValid(null)); }