Beispiel #1
0
        public void GetEndpoint3()
        {
            // When
            // Product List is not empty
            // p.Code is not exist

            // Mock Product
            var product = new InternalEndpointsParser.Product();

            product.Code = "ProductCode";
            product.LocationServiceCode     = "LocationServiceCode";
            product.DocumentId              = "DocumentId";
            product.RegionalEndpoints       = new Dictionary <string, string>();
            product.GlobalEndpoint          = "GlobalEndpoint";
            product.RegionalEndpointPattern = "RegionalEndpointPattern";

            // Mock Product List
            var productList = new List <InternalEndpointsParser.Product>();

            // Mock InternalEndpointsParser
            var mockInstance = new Mock <InternalEndpointsParser>();

            mockInstance.Setup(foo => foo.GetProducts()).Returns(productList);
            var instance = mockInstance.Object;

            var result = instance.GetEndpoint("regionIdKey", "ProductCodeNotExist");

            Assert.Equal("regionIdKey", result.Name);
            Assert.Empty(result.ProductDomains);
            Assert.Empty(result.RegionIds);
        }
Beispiel #2
0
        public void GetEndpoint4()
        {
            // When Product List is not empty
            // p.Code is exist

            // Mock Product
            // regionKey is not exist
            // regionSet is empty
            // GlobalEndpoint is empty
            var product = new InternalEndpointsParser.Product();

            product.Code = "ProductCode";
            product.LocationServiceCode     = "LocationServiceCode";
            product.DocumentId              = "DocumentId";
            product.RegionalEndpoints       = new Dictionary <string, string>();
            product.GlobalEndpoint          = "";
            product.RegionalEndpointPattern = "RegionalEndpointPattern";

            // Mock Product List
            var productList = new List <InternalEndpointsParser.Product>();

            productList.Add(product);

            // Mock InternalEndpointsParser
            var mockInstance = new Mock <InternalEndpointsParser>();

            mockInstance.Setup(foo => foo.GetProducts()).Returns(productList);
            var instance = mockInstance.Object;

            var result = instance.GetEndpoint("regionKey", "ProductCode");

            Assert.Null(result);
        }
Beispiel #3
0
 public void TestCreateProduct()
 {
     var product = new InternalEndpointsParser.Product()
     {
         Code = "ecs",
         LocationServiceCode     = "ecs",
         DocumentId              = "12546",
         RegionalEndpoints       = new Dictionary <string, string>(),
         GlobalEndpoint          = "test.aliyuncs.com",
         RegionalEndpointPattern = "[a-zA-Z0-9].aliyuncs.com"
     };
 }