public void CanOverrideDiscoveryClient() { var client = new TestServiceDiscovery(); settings.AddServiceDiscovery(client); settings.GetDiscoveryClient().Should().Be(client); }
public void Resolver_ReturnsRegisteredType_ByName(string method, string expected) { var discovery = new TestServiceDiscovery(); var remoteuri = "http://remoteUri:1234/"; discovery.DtoTypes.Add(typeof(TestDTO2), remoteuri); plugin.Settings.AddServiceDiscovery(discovery); Consul.ResolveTypedUrl(new JsonServiceClient("http://localhost"), method, new TestDTO2()).Should().Be(remoteuri.CombineWith(expected)); }
public void Resolver_ReturnsDefaultRoute_ByDTOTypeName() { var remoteuri = "http://remoteuri:1234/api/"; var expected = remoteuri.CombineWith("/json/reply/ConsulTests.TestDTO"); var discovery = new TestServiceDiscovery(); discovery.DtoTypes.Add(typeof(TestDTO), remoteuri); plugin.Settings.AddServiceDiscovery(discovery); Consul.ResolveTypedUrl(new JsonServiceClient("http://localhost/"), "GET", new TestDTO()).Should().Be(expected); }
public void Gateway_ReturnsCorrectly_ForNonLocalTypes() { var resolver = new TestServiceDiscovery(new KeyValuePair <Type, string>(typeof(ConsulServiceGatewayFactoryTests), "http://banana")); var gateway = new ConsulServiceGatewayFactory(uri => new CsvServiceClient(uri) { Version = 123 }, resolver); gateway.LocalTypes.Clear(); var serviceGateway = gateway.GetGateway(typeof(ConsulServiceGatewayFactoryTests)); var client = serviceGateway.Should().BeOfType <CachedServiceClient>().Subject; client.Version.Should().Be(123); }