示例#1
0
        public void SydneyServiceConstructorCallsValidateOnConfig()
        {
            SydneyServiceConfig config = A.Fake <SydneyServiceConfig>();

            config.Scheme = Uri.UriSchemeHttp;
            config.Host   = "*";
            config.Port   = 80;

            SydneyService service = new SydneyService(config);

            A.CallTo(() => config.Validate()).MustHaveHappenedOnceExactly();
        }
示例#2
0
        public void ValidateThrowsExceptionForInvalidScheme()
        {
            SydneyServiceConfig config = new SydneyServiceConfig
            {
                Scheme = "foo"
            };

            Exception exception = Record.Exception(() => config.Validate());

            Assert.IsType <ArgumentException>(exception);
            Assert.Equal(
                "SydneyServiceConfig.Scheme must be one of \"http\" or \"https\".",
                exception.Message);
        }
示例#3
0
        public void ValidateThrowsExceptionForInvalidHost()
        {
            SydneyServiceConfig config = new SydneyServiceConfig
            {
                Scheme = Uri.UriSchemeHttp,
                Host   = null
            };

            Exception exception = Record.Exception(() => config.Validate());

            Assert.IsType <ArgumentException>(exception);
            Assert.Equal(
                "SydneyServiceConfig.Host must be a valid non-empty string. Use \"*\" or \"+\" to match all hosts.",
                exception.Message);
        }
示例#4
0
        public void ValidateThrowsExceptionForInvalidPort()
        {
            SydneyServiceConfig config = new SydneyServiceConfig
            {
                Scheme = Uri.UriSchemeHttp,
                Host   = "*",
                Port   = 0
            };

            Exception exception = Record.Exception(() => config.Validate());

            Assert.IsType <ArgumentException>(exception);
            Assert.Equal(
                "SydneyServiceConfig.Port must be a valid port value between 1 and 65535.",
                exception.Message);
        }
示例#5
0
        public void ValidateDoesNotThrowExceptionForValidConfig()
        {
            SydneyServiceConfig config =
                new SydneyServiceConfig(
                    Uri.UriSchemeHttp,
                    "*",
                    80,
                    true);

            // Call should not throw exceptions.
            config.Validate();

            Assert.Equal(Uri.UriSchemeHttp, config.Scheme);
            Assert.Equal("*", config.Host);
            Assert.Equal(80, config.Port);
            Assert.True(config.ReturnExceptionMessagesInResponse);
        }