public void IsValid() { var v = new MaxAttribute(); Assert.IsTrue(v.IsValid(0, null)); v= new MaxAttribute(1000); Assert.IsTrue(v.IsValid(3, null)); Assert.IsTrue(v.IsValid(200.0m, null)); Assert.IsTrue(v.IsValid(1000, null)); Assert.IsTrue(v.IsValid(null, null)); Assert.IsTrue(v.IsValid("5", null)); Assert.IsFalse(v.IsValid(1001, null)); Assert.IsFalse(v.IsValid("aaa", null)); Assert.IsFalse(v.IsValid(new object(), null)); Assert.IsFalse(v.IsValid(long.MaxValue, null)); }
public void Extreme() { var v = new MaxAttribute(10000); Assert.IsTrue(v.IsValid(10000, null)); Assert.IsTrue(v.IsValid(10000L, null)); Assert.IsTrue(v.IsValid(123UL, null)); Assert.IsTrue(v.IsValid(123U, null)); Assert.IsTrue(v.IsValid((ushort)5, null)); Assert.IsTrue(v.IsValid((short)5, null)); Assert.IsTrue(v.IsValid(true, null)); Assert.IsTrue(v.IsValid((byte)100, null)); Assert.IsTrue(v.IsValid((sbyte)100, null)); Assert.IsTrue(v.IsValid(AEnum.A, null)); Assert.IsTrue(v.IsValid(CarOptions.Spoiler | CarOptions.FogLights, null)); Assert.IsTrue(v.IsValid('A', null)); Assert.IsTrue(v.IsValid(9999.99999f, null)); Assert.IsTrue(v.IsValid(9999.9999999999999999999999999d, null)); Assert.IsFalse(v.IsValid(decimal.MaxValue, null)); Assert.IsFalse(v.IsValid(decimal.MaxValue.ToString(), null)); Assert.IsFalse(v.IsValid(double.MaxValue, null)); Assert.IsFalse(v.IsValid("1" + double.MaxValue, null)); }