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 }"); }
public NonObligatedCategoryValueTests() { attribute = (TonnageValueAttribute)Attribute.GetCustomAttribute(typeof(NonObligatedCategoryValue).GetProperty("Tonnage"), typeof(TonnageValueAttribute)); }
public ObligatedCategoryValueTests() { b2cAttribute = (TonnageValueAttribute)Attribute.GetCustomAttribute(typeof(ObligatedCategoryValue).GetProperty("B2C"), typeof(TonnageValueAttribute)); b2bAttribute = (TonnageValueAttribute)Attribute.GetCustomAttribute(typeof(ObligatedCategoryValue).GetProperty("B2B"), typeof(TonnageValueAttribute)); }