public void testExecute_uriValidate_assertResults()
        {
            var fakeDiagnostics = new FakeDiagnostics(typeof(UriValid<>));
            PolicyOperator<string>.URI_VALIDATE.Warning += fakeDiagnostics.OnWarn;

            // valid
            Assert.True(PolicyOperator<string>.URI_VALIDATE.Execute("http://www.cerner.com/CPS"));// not found
            Assert.False(PolicyOperator<string>.URI_VALIDATE.Execute("http://www.google.com/333333"));
            Assert.Equal("http://www.google.com/333333:The remote server returned an error: (404) Not Found.", fakeDiagnostics.ActualErrorMessages[0]);

            // host not found
            Assert.False(PolicyOperator<string>.URI_VALIDATE.Execute("http://bogus.unit.test.ccc"));
            Assert.Equal("http://bogus.unit.test.ccc:The remote name could not be resolved: 'bogus.unit.test.ccc'", fakeDiagnostics.ActualErrorMessages[1]);

            // invalid
            Assert.False(PolicyOperator<string>.URI_VALIDATE.Execute("htt://invalid.lab"));
            Assert.Equal("htt://invalid.lab:The URI prefix is not recognized.", fakeDiagnostics.ActualErrorMessages[2]);

            // invalid
            Assert.False(PolicyOperator<string>.URI_VALIDATE.Execute("http//invalid.lab"));
            Assert.Equal("http//invalid.lab:Invalid URI: The format of the URI could not be determined.", fakeDiagnostics.ActualErrorMessages[3]);
        }
Exemplo n.º 2
0
        public void testExecute_uriValidate_assertResults()
        {
            var fakeDiagnostics = new FakeDiagnostics(typeof(UriValid <>));

            PolicyOperator <string> .URI_VALIDATE.Warning += fakeDiagnostics.OnWarn;

            // valid
            Assert.True(PolicyOperator <string> .URI_VALIDATE.Execute("http://www.cerner.com/CPS"));// not found
            Assert.False(PolicyOperator <string> .URI_VALIDATE.Execute("http://www.google.com/333333"));
            Assert.Equal("http://www.google.com/333333:The remote server returned an error: (404) Not Found.", fakeDiagnostics.ActualErrorMessages[0]);

            // host not found
            Assert.False(PolicyOperator <string> .URI_VALIDATE.Execute("http://bogus.unit.test.ccc"));
            Assert.Equal("http://bogus.unit.test.ccc:The remote name could not be resolved: 'bogus.unit.test.ccc'", fakeDiagnostics.ActualErrorMessages[1]);

            // invalid
            Assert.False(PolicyOperator <string> .URI_VALIDATE.Execute("htt://invalid.lab"));
            Assert.Equal("htt://invalid.lab:The URI prefix is not recognized.", fakeDiagnostics.ActualErrorMessages[2]);

            // invalid
            Assert.False(PolicyOperator <string> .URI_VALIDATE.Execute("http//invalid.lab"));
            Assert.Equal("http//invalid.lab:Invalid URI: The format of the URI could not be determined.", fakeDiagnostics.ActualErrorMessages[3]);
        }