Example #1
0
        public void FindServiceUriByType(TestServiceType serviceType, string expectedUri)
        {
            var provider = new ServiceDiscoveryProvider(GetConfiguration(), ServiceDiscoveryOptions.Default);

            Uri uri = provider.GetService(serviceType);

            uri.AbsoluteUri.Should().Be(expectedUri);
        }
Example #2
0
        public void ThrowExceptionIfServiceDoesntExist()
        {
            var provider = new ServiceDiscoveryProvider(GetConfiguration(), ServiceDiscoveryOptions.Default);

            Action action = () => provider.GetService("doesntExist");

            action.Should().Throw <ArgumentException>();
        }
Example #3
0
        public void ThrowExceptionIfServiceTypeWithoutAttribute()
        {
            var provider = new ServiceDiscoveryProvider(GetConfiguration(), ServiceDiscoveryOptions.Default);

            Action action = () => provider.GetService(TestServiceType.WithtoutParameter);

            action.Should().Throw <ArgumentException>();
        }
Example #4
0
        public void FindServiceUriByNameInAnotherSection()
        {
            var provider = new ServiceDiscoveryProvider(
                GetConfiguration(),
                new ServiceDiscoveryOptions()
            {
                SectionName = "ApiServices"
            });

            Uri uri = provider.GetService("ToDos");

            uri.AbsoluteUri.Should().Be("http://localhost:9004/");
        }
Example #5
0
        public void AllowServiceNameAsHost(string serviceName)
        {
            var provider = new ServiceDiscoveryProvider(GetConfiguration(),
                                                        new ServiceDiscoveryOptions()
            {
                AllowServiceNameAsHost = true
            });

            Uri uri = provider.GetService(serviceName);

            uri.Scheme.Should().Be("http");
            uri.Host.Should().Be(serviceName);
            uri.Port.Should().Be(80);
        }