Example #1
0
        public void Given_that_two_values_are_selected_Then_Validation_should_return_error2()
        {
            //Given
            var target = new OneDropDownSelected("LinkToSiteId,LinkToGroupId");
            var otherObject = new TestClass { LinkToSiteId = null, LinkToGroupId = null};
            var testContext = new ValidationContext(otherObject, null, null);

            //When            
            TestDelegate exceptionResult = () => target.Validate(10, testContext);
            
            //Then
            Assert.DoesNotThrow(exceptionResult);
        }
Example #2
0
        public void Given_that_two_values_are_selected_Then_Validation_should_return_error()
        {
            //Given
            var target = new OneDropDownSelected("LinkToSiteId");            
            var otherObject = new TestClass {LinkToSiteId = 10};            
            var testContext = new ValidationContext(otherObject, null, null);

            //When
            TestDelegate exceptionResult = () => target.Validate(30, testContext);           

            //Then 
            var exception = Assert.Throws<ValidationException>(exceptionResult);
            Assert.That(exception.Message, Is.EqualTo("Only One Option Is Allowed"));            
        }