示例#1
0
        public void TestQueryString()
        {
            HttpRequestMessage message = new HttpRequestMessage();
            var optOne   = new QueryOptions();
            var optTwo   = new QueryOptions();
            var optThree = new QueryOptions();

            optOne.AddFilter("title", "Samplify Client Test");
            optOne.AddFilter("state", StateConstants.Provisioned);
            optTwo.AddSort("createdAt", SortDirection.Asc);
            optTwo.AddSort("extProjectId", SortDirection.Desc);
            optThree.AddFilter("title", "Samplify Client Test");
            optThree.AddFilter("state", StateConstants.Provisioned);
            optThree.AddSort("createdAt", SortDirection.Asc);
            optThree.AddSort("extProjectId", SortDirection.Desc);

            var tests = new Dictionary <QueryOptions, string>();

            tests.Add(optOne, "/projects?title=Samplify+Client+Test&amp;state=PROVISIONED");
            tests.Add(optTwo, "/projects?sort=createdAt:asc,extProjectId:desc");
            tests.Add(optThree, "/projects?title=Samplify+Client+Test&amp;state=PROVISIONED&amp;sort=createdAt:asc,extProjectId:desc");

            SamplifyClient testClient = new MockSamplifyClient((request) =>
            {
                message = request;
            });

            foreach (var t in tests)
            {
                testClient.GetAllProjects(t.Key).Wait();
                Assert.NotNull(message);
                Assert.Equal(message.RequestUri.PathAndQuery, t.Value);
            }
        }