public void Common_StringValidator_ValidateValueInRangeAttribute_ShouldThrowException_WithEmptyValue()
        {
            CustomAttributeObject obj = new CustomAttributeObject(string.Empty);
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.HasExceptionKey(ValidateValueInRangeAttribute.NameExceptionKey));
        }
        public void Common_StringValidator_ValidateValueInRangeAttribute_ShouldThrowException_WithValueGreaterThanUpperBound()
        {
            CustomAttributeObject obj = new CustomAttributeObject("123456789123456798");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.Errors.Count == 1 && ex.HasExceptionKey(ValidateValueInRangeAttribute.NameExceptionKey));
        }
        public void Common_Validator_ValidateUniqueAttribute_ShouldBeSuccess_WithValidName()
        {
            CustomAttributeObject obj = new CustomAttributeObject("132");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.Errors.Count == 0);
        }
        public void Common_StringValidator_ValidateValueInRangeAttribute_ShouldBeSuccess_WithValidValueInRange()
        {
            CustomAttributeObject obj = new CustomAttributeObject("123456798");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.Errors.Count == 0);
        }
        public void Common_StringValidator_ValidateValueInCollectionAttribute_ShouldThrowException_WithInvalidNumber()
        {
            CustomAttributeObject obj = new CustomAttributeObject("abc");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.HasExceptionKey(ValidateValueInCollectionAttribute.NameExceptionKey));
        }
        public void Common_StringValidator_ValidateRequireAttribute_ShouldThrowOnlyExceptionForName_WithEmptyName()
        {
            CustomAttributeObject obj = new CustomAttributeObject(string.Empty, "Test Subject");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.Errors.Count == 1 && ex.HasExceptionKey(ValidateRequireAttribute.NameExceptionKey));
        }
        public void Common_StringValidator_ValidateRequireAttribute_ShouldBeSuccess_WithValidObject()
        {
            CustomAttributeObject obj = new CustomAttributeObject("Test value", "Test Subject");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.Errors.Count == 0);
        }
        public void Common_Validator_ValidateUniqueAttribute_ShouldThrowException_WithDuplicatedName()
        {
            CreatePermissionRequest request = new CreatePermissionRequest("abc", "dsfsdfs", "sdfdfs");
            IPermissionService      service = IoC.Container.Resolve <IPermissionService>();

            service.Create(request);

            CustomAttributeObject obj = new CustomAttributeObject("abc");
            IValidationException  ex  = ValidationHelper.Validate(obj);

            Assert.IsTrue(ex.HasExceptionKey(ValidateUniqueAttribute.NameExceptionKey));
        }
Ejemplo n.º 9
0
        public void Should_IgnoreByCustomAttributeName()
        {
            var object1 = new CustomAttributeObject(1, "A string");
            var object2 = new CustomAttributeObject(1, "A different string");

            var diffOptions = new DiffOptions(new List <object> {
                "DescriptionAttribute"
            });
            var diff = object1.Diff(object2, ComparisonOptions.All, diffOptions);

            Assert.AreEqual(0, diff.Count);
        }