예제 #1
0
        public void Given_that_main_site_is_selected_Then_validation_return_no_error()
        {
            //Given
            var target = new Application.Request.Attributes.AtLeastOneDropDownSelectedMainSite("LinkToGroupId-IsMainSite");
            var otherObject = new TestClass { LinkToGroupId = null, IsMainSite = true};
            var testContext = new ValidationContext(otherObject, null, null);

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

            //Then
            Assert.DoesNotThrow(exceptionResult);
        }
예제 #2
0
        public void Given_that_normal_site_is_selected_Then_validation_return_error()
        {
            //Given
            var target = new Application.Request.Attributes.AtLeastOneDropDownSelectedMainSite("LinkToGroupId-IsMainSite");
            var otherObject = new TestClass { LinkToGroupId = null, IsMainSite = false };
            var testContext = new ValidationContext(otherObject, null, null);

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

            //Then
            var ex = Assert.Throws<ValidationException>(exceptionResult);
            Assert.That(ex.Message, Is.EqualTo("At Least One Should Be Selected"));
        }