public List <Endpoint> GetEndpoints(String product, String regionId, String serviceCode, String endpointType) { if (product == null) { return(endpoints); } if (null == endpoints) { Endpoint endpoint = null; if (serviceCode != null) { endpoint = remoteProvider.GetEndpoint(regionId, product, serviceCode, endpointType, credential, locationConfig); } if (endpoint == null) { endpoint = iendpoints.GetEndpoint(regionId, product); } if (endpoint != null) { endpoints = new List <Endpoint>(); endpoints.Add(endpoint); CacheTimeHelper.AddLastClearTimePerProduct(product, regionId, DateTime.Now); } else { throw new ClientException("SDK.InvalidRegionId", "Can not find endpoint to access."); } } else if (Endpoint.FindProductDomain(regionId, product, endpoints) == null || CacheTimeHelper.CheckCacheIsExpire(product, regionId)) { Endpoint endpoint = null; if (serviceCode != null) { endpoint = remoteProvider.GetEndpoint(regionId, product, serviceCode, endpointType, credential, locationConfig); } if (endpoint == null) { endpoint = iendpoints.GetEndpoint(regionId, product); } if (endpoint != null) { foreach (String region in endpoint.RegionIds) { foreach (ProductDomain productDomain in endpoint.ProductDomains) { AddEndpoint(endpoint.Name, region, product, productDomain.DomianName, false); CacheTimeHelper.AddLastClearTimePerProduct(product, region, DateTime.Now); } } } } return(endpoints); }
public void GetEndpointWhenResponseIsNull() { DescribeEndpointResponse response = null; var mock = new Mock <DescribeEndpointService>(); //String regionId, String serviceCode, String endpointType,Credential credential,LocationConfig locationConfig mock.Setup(foo => foo.DescribeEndpoint( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Credential>(), It.IsAny <LocationConfig>() )).Returns(response); DescribeEndpointService describeEndpointService = mock.Object; RemoteEndpointsParser instance = new RemoteEndpointsParser(); instance.SetDescribeEndpointService(describeEndpointService); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", "serviceCode", "endpointType", credential, locationConfig); Assert.Null(result); }
public void GetEndpointWhenResponseIsNotNull() { DescribeEndpointResponse response = new DescribeEndpointResponse(); response.RegionId = "RegionId"; response.Endpoint = "Endpoint"; var mock = new Mock <DescribeEndpointService>(); mock.Setup(foo => foo.DescribeEndpoint( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Credential>(), It.IsAny <LocationConfig>() )).Returns(response); DescribeEndpointService describeEndpointService = mock.Object; RemoteEndpointsParser instance = new RemoteEndpointsParser(); instance.SetDescribeEndpointService(describeEndpointService); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", "serviceCode", "endpointType", credential, locationConfig); Assert.IsType <Endpoint>(result); Assert.NotNull(result); Assert.Equal("RegionId", result.Name); Assert.NotEmpty(result.ProductDomains); Assert.NotEmpty(result.RegionIds); }
public void GetEndpointWhenResponseIsNotNull() { var response = new DescribeEndpointResponse(); response.RegionId = "RegionId"; response.Endpoint = "Endpoint"; var mock = new Mock <DescribeEndpointService>(); mock.Setup(foo => foo.DescribeEndpoint( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Credential>(), It.IsAny <LocationConfig>() )).Returns(response); var instance = new RemoteEndpointsParser(); var credential = new Credential(); var locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", "serviceCode", "endpointType", credential, locationConfig); Assert.Null(result); }
public void GetEndpoint() { var instance = new RemoteEndpointsParser(); Assert.Throws <NotSupportedException>( () => { instance.GetEndpoint("", ""); } ); }
public void GetEndpointWhenServiceCodeIsNull() { RemoteEndpointsParser instance = new RemoteEndpointsParser(); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", null, "endpointType", credential, locationConfig); Assert.Null(result); }
private void FillEndPointFromLocation(String regionId, String product, Credential credential, String locationProduct) { Endpoint endpoint = remoteProvider.GetEndpoint(regionId, product, locationProduct, credential, locationConfig); if (endpoint != null) { foreach (String region in endpoint.RegionIds) { foreach (ProductDomain productDomain in endpoint.ProductDomains) { AddLocationEndpoint(endpoint.Name, region, product, productDomain.DomianName); } } } }
private void FillEndpointFromLocation(String regionId, String product, Credential credential, String locationProduct, String locationEndpointType) { Endpoint endpoint = remoteProvider.GetEndpoint(regionId, product, locationProduct, credential, locationConfig, locationEndpointType); if (endpoint != null) { foreach (String region in endpoint.RegionIds) { foreach (ProductDomain productDomain in endpoint.ProductDomains) { AddLocationEndpoint(endpoint.Name, region, product, productDomain.DomianName); CacheTimeHelper.AddLastClearTimePerProduct(product, regionId, DateTime.Now); } } } }
public virtual Endpoint GetEndpointByRemoteProvider(string regionId, string product, string serviceCode, string endpointType) { return(remoteProvider.GetEndpoint(regionId, product, serviceCode, endpointType, credential, locationConfig)); }