public void GetDefaultInstanceId_ReturnsExpected() { ConsulDiscoveryOptions options = new ConsulDiscoveryOptions() { ServiceName = "serviceName" }; var config = new ConfigurationBuilder().Build(); var result = ConsulRegistration.GetDefaultInstanceId(options, config); Assert.StartsWith("serviceName:", result); config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string>() { { "vcap:application:instance_id", "vcapid" } }) .Build(); result = ConsulRegistration.GetDefaultInstanceId(options, config); Assert.Equal("serviceName:vcapid", result); config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string>() { { "spring:application:instance_id", "springid" } }) .Build(); result = ConsulRegistration.GetDefaultInstanceId(options, config); Assert.Equal("serviceName:springid", result); }
public void GetDefaultInstanceId_ReturnsExpected() { var options = new ConsulDiscoveryOptions(); var appsettings = new Dictionary <string, string>() { { "consul:discovery:serviceName", "serviceName" } }; var config = TestHelpers.GetConfigurationFromDictionary(appsettings); var result = ConsulRegistration.GetDefaultInstanceId(new ApplicationInstanceInfo(config)); Assert.StartsWith("serviceName:", result); appsettings.Add("spring:application:instance_id", "springid"); config = TestHelpers.GetConfigurationFromDictionary(appsettings); result = ConsulRegistration.GetDefaultInstanceId(new ApplicationInstanceInfo(config)); Assert.Equal("serviceName:springid", result); appsettings.Add("vcap:application:instance_id", "vcapid"); config = TestHelpers.GetConfigurationFromDictionary(appsettings); result = ConsulRegistration.GetDefaultInstanceId(new CloudFoundryApplicationOptions(config)); Assert.Equal("serviceName:vcapid", result); }