예제 #1
0
 public FunctionUnitTests()
 {
     Console.WriteLine("FunctionUnitTests Setup .....");
     Service = "test-csharp-" + TestConfig.RandomString(8);
     tf      = new TestConfig();
 }
예제 #2
0
        public void TestListServices()
        {
            string prefix = "csharp_test_list_" + TestConfig.RandomString(8);

            string[] names = { prefix + "abc", prefix + "abd", prefix + "ade", prefix + "bcd", prefix + "bde", prefix + "zzz" };
            int      i     = 0;
            Dictionary <string, string> tags;

            foreach (string element in names)
            {
                var resp = tf.Client.CreateService(new CreateServiceRequest(element));
                Assert.Equal(200, resp.StatusCode);
                string resArn = String.Format("services/{0}", element);

                tags = new Dictionary <string, string> {
                    { "k3", "v3" },
                    { "k1", "v1" },
                };
                if (i % 2 == 1)
                {
                    tags = new Dictionary <string, string> {
                        { "k3", "v3" },
                        { "k2", "v2" },
                    };
                }

                var tResp = tf.Client.TagResource(new TagResourceRequest(resArn, tags));
                Assert.Equal(200, tResp.StatusCode);
                Assert.NotNull(tResp.GetRequestID());

                this.ServiceNames.Add(element);
                i++;
            }

            var response1 = tf.Client.ListServices(new ListServicesRequest(2, prefix + "b"));

            Assert.Equal(2, response1.Data.Services.GetLength(0));
            Assert.Equal(prefix + "bcd", response1.Data.Services[0].ServiceName);
            Assert.Equal(prefix + "bde", response1.Data.Services[1].ServiceName);

            var response2 = tf.Client.ListServices(new ListServicesRequest(100, prefix));

            Assert.Equal(6, response2.Data.Services.GetLength(0));

            tags = new Dictionary <string, string> {
                { "k3", "v3" },
            };
            var response = tf.Client.ListServices(new ListServicesRequest(20, prefix + "a", null, null, null, tags));

            Assert.Equal(3, response.Data.Services.GetLength(0));

            tags = new Dictionary <string, string> {
                { "k1", "v1" },
            };
            response = tf.Client.ListServices(new ListServicesRequest(20, prefix + "a", null, null, null, tags));
            Assert.Equal(2, response.Data.Services.GetLength(0));

            tags = new Dictionary <string, string> {
                { "k2", "v2" },
            };
            response = tf.Client.ListServices(new ListServicesRequest(20, prefix + "a", null, null, null, tags));
            Assert.Equal(1, response.Data.Services.GetLength(0));

            tags = new Dictionary <string, string> {
                { "k1", "v1" },
                { "k2", "v2" },
            };
            response = tf.Client.ListServices(new ListServicesRequest(20, prefix + "a", null, null, null, tags));
            Assert.Equal(0, response.Data.Services.GetLength(0));
        }
예제 #3
0
 public CustomDomainTestUnitTests()
 {
     Console.WriteLine("CustomDomainUnitTests Setup .....");
     tf = new TestConfig();
 }