public void Should_validate_tagAttributes_with_enum() { Validate(tag => new ConstantAttribute("One", tag), null); Validate(tag => new ConstantAttribute("two", tag), null); Validate(tag => new ConstantAttribute("Two,Three", tag), null); Validate(tag => new ConstantAttribute("*", tag), null); Validate(tag => new ConstantAttribute("Four", tag), EnumTagAttributeValidator.InvalidValueException("Four", Enum.GetValues(typeof(OneTwoThree)))); Validate(tag => new ConstantAttribute("Two,Wrong", tag), EnumTagAttributeValidator.InvalidValueException("Wrong", Enum.GetValues(typeof(OneTwoThree)))); Validate(tag => null, null); }
private void Validate(Func <TestTag, ITagAttribute> action, TagException expectedException) { // Given var tag = CreateTag(action); var validator = new EnumTagAttributeValidator(); // When TagException result = null; try { validator.Validate(tag); } catch (TagException e) { result = e; } Assert.That(result?.Message, Is.EqualTo(expectedException?.Message), tag.EnumValue?.ToString()); }