public void ValidateTest() { ImageUrlAttributeType uut = new ImageUrlAttributeType { Key = "Some Image", Required = false }; Assert.DoesNotThrow(() => uut.Validate()); // Null key is not okay uut.Key = null; ListedValidationException e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); }
public void ValidateTest() { IntegerAttributeType uut = new IntegerAttributeType { Key = "Some Int", DefaultValue = null, MaxValue = null, MinValue = null, Required = false }; Assert.DoesNotThrow(() => uut.Validate()); // Having a Max, min, and default should be okay. uut.DefaultValue = 10; uut.MinValue = 0; uut.MaxValue = 100; Assert.DoesNotThrow(() => uut.Validate()); // Having a default value outside of the range should throw an exception. uut.DefaultValue = -1; ListedValidationException e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); uut.DefaultValue = null; // Not having a default value with a min/max should work okay. Assert.DoesNotThrow(() => uut.Validate()); // Having a max < min should throw. uut.MinValue = 101; e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); // Just having a default value should be okay. uut.MinValue = null; uut.MaxValue = null; uut.DefaultValue = 10; Assert.DoesNotThrow(() => uut.Validate()); // Null key is not okay uut.Key = null; e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); }
public void ValidateTest() { AssetNameAttributeType uut = new AssetNameAttributeType { Key = "Some Asset" }; Assert.DoesNotThrow(() => uut.Validate()); // Required set to false will cause a validation error, // this is ALWAYS required. uut.Required = false; ListedValidationException e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); uut.Required = true; // Null key will throw exceptions. uut.Key = null; e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); }
public void ValidateTest() { StringAttributeType uut = new StringAttributeType { Key = "Some String", DefaultValue = null, Required = false }; Assert.DoesNotThrow(() => uut.Validate()); // Having a default value should be okay. uut.DefaultValue = "Hello"; Assert.DoesNotThrow(() => uut.Validate()); // Not having a default value with a min/max should work okay. Assert.DoesNotThrow(() => uut.Validate()); // Null key is not okay uut.Key = null; ListedValidationException e = Assert.Throws <ListedValidationException>(() => uut.Validate()); Assert.AreEqual(1, e.Errors.Count()); }