public void IsValid_GivenRelatedPropertyDoesNotExist_ValidationExceptionExpected()
        {
            var tonnageValue = new TestTonnageValueNonRelatedProperty();
            var validationContexWithInvalidModel = new ValidationContext(tonnageValue);
            var attribute = new TonnageValueAttribute(CategoryIdProperty);

            Action action = () => attribute.Validate(1, validationContexWithInvalidModel);

            action.Should().Throw <ValidationException>().WithMessage($"Property {CategoryIdProperty} does not exist");
        }
        public void IsValid_GivenRelatedPropertyIsNotWeeeCategoryValue_ValidationExceptionExpected()
        {
            var tonnageValue = new TestTonnageValueRelatedPropertyNotOfCorrectType()
            {
                Category = 15
            };
            var validationContexWithInvalidModel = new ValidationContext(tonnageValue);
            var attribute = new TonnageValueAttribute(CategoryIdProperty);

            Action action = () => attribute.Validate(1, validationContexWithInvalidModel);

            action.Should().Throw <ValidationException>().WithMessage($"Property {CategoryIdProperty} should be of type { typeof(WeeeCategory).Name }");
        }
Exemple #3
0
 public NonObligatedCategoryValueTests()
 {
     attribute = (TonnageValueAttribute)Attribute.GetCustomAttribute(typeof(NonObligatedCategoryValue).GetProperty("Tonnage"), typeof(TonnageValueAttribute));
 }
Exemple #4
0
 public ObligatedCategoryValueTests()
 {
     b2cAttribute = (TonnageValueAttribute)Attribute.GetCustomAttribute(typeof(ObligatedCategoryValue).GetProperty("B2C"), typeof(TonnageValueAttribute));
     b2bAttribute = (TonnageValueAttribute)Attribute.GetCustomAttribute(typeof(ObligatedCategoryValue).GetProperty("B2B"), typeof(TonnageValueAttribute));
 }