コード例 #1
0
        private void CreateConfigurationService(string service, string id, string body)
        {
            var handler  = new ConfigurationServiceManager();
            var response = handler.ConfigurationService <object>(service, id, body, System.Net.Http.HttpMethod.Put);

            PrAssume.That(response, PrIs.SuccessfulResponse());
        }
コード例 #2
0
        private void GetAndVerifyConfigurationService(string service, string id, string body)
        {
            var handler  = new ConfigurationServiceManager();
            var response = handler.ConfigurationService <object>(service, id, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(JObject.Parse(response.Result.ToString()), PrIs.EqualTo(JObject.Parse(body)));
        }
コード例 #3
0
        public void DuplicateParamenterConfigurationServiceTest(Method method, Parameters parameter, DuplicateValues duplicateValue)
        {
            var    request  = new Dictionary <string, string>(DefaultParameters);
            var    handler  = new ConfigurationServiceManager();
            string bodyJson = DuplicateMapping[parameter](duplicateValue, request);
            var    response = handler.ConfigurationService <object>(request["service"], request["id"], bodyJson, System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
コード例 #4
0
 private ApiResponse <object> Response(ConfigurationServiceManager handler, Method method)
 {
     if (method == Method.Create)
     {
         return(handler.ConfigurationService <object>(DefaultParameters["service"], DefaultParameters["id"], DefaultParameters["body"], System.Net.Http.HttpMethod.Put));
     }
     else
     {
         return(handler.ConfigurationService <object>(DefaultParameters["service"], DefaultParameters["id"], System.Net.Http.HttpMethod.Get));
     }
 }
コード例 #5
0
        public void ConfigurationServiceValidCreateTest(Parameters parameter, Valid inputType)
        {
            var handler = new ConfigurationServiceManager();
            var request = new Dictionary <string, string>(DefaultParameters);

            request[parameter.ToString().ToLower()] = ValidCreateMapping[inputType];

            var response = handler.ConfigurationService <object>(request["service"], request["id"], request["body"], System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.Result, PrIs.Null);
        }
コード例 #6
0
        public void ConfigurationServiceValidGetTest(Parameters parameter, Valid inputType)
        {
            var handler = new ConfigurationServiceManager();
            var request = new Dictionary <string, string>(DefaultParameters);

            request[parameter.ToString().ToLower()] = ValidGetMapping[inputType];
            request["body"] = BodyJson.Replace("db01", Utils.RandomString(20));

            //Create configuration service
            CreateConfigurationService(request["service"], request["id"], request["body"]);

            //Get and verify configuration service
            GetAndVerifyConfigurationService(request["service"], request["id"], request["body"]);
        }
コード例 #7
0
        public void CreateConfigurationServiceByOtherHttpMethod(HttpMethod inputType)
        {
            var handler = new ConfigurationServiceManager();
            var request = new Dictionary <string, string>(DefaultParameters);

            var httpMethod = new Dictionary <HttpMethod, System.Net.Http.HttpMethod>()
            {
                [HttpMethod.GET]    = System.Net.Http.HttpMethod.Get,
                [HttpMethod.DELETE] = System.Net.Http.HttpMethod.Delete,
                [HttpMethod.POST]   = System.Net.Http.HttpMethod.Post,
            };

            var response = handler.ConfigurationService <object>(request["service"], request["id"], request["body"], httpMethod[inputType]);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
コード例 #8
0
        public void ConfigurationServiceInvalidSpecialTest(InvalidSpecial inputType, Method method)
        {
            var request = GetParameters[inputType](method);
            var handler = new ConfigurationServiceManager();
            ApiResponse <object> response = null;

            if (method == Method.Create)
            {
                var contentType = inputType == InvalidSpecial.WrongContentType ? "text/html" : "application/json";
                response = handler.ConfigurationService <object>(request["service"], request["id"], request["body"], System.Net.Http.HttpMethod.Put, contentType);
            }
            else
            {
                response = handler.ConfigurationService <object>(request["service"], request["id"], System.Net.Http.HttpMethod.Get);
            }
            PrAssert.That(response, PrIs.ErrorResponse());
        }
コード例 #9
0
        public void CreateAndThenUpdateConfigurationServiceTest()
        {
            var handler = new ConfigurationServiceManager();
            var request = new Dictionary <string, string>(DefaultParameters);

            request["body"]    = BodyJson.Replace("db01", Utils.RandomString(20));
            request["service"] = "create/update";

            //Create configuration service
            CreateConfigurationService(request["service"], request["id"], request["body"]);

            //Update configuration service with new body json
            request["body"] = BodyJson.Replace("db01", Utils.RandomString(20));
            CreateConfigurationService(request["service"], request["id"], request["body"]);

            //Get and verify configuration service
            GetAndVerifyConfigurationService(request["service"], request["id"], request["body"]);
        }
コード例 #10
0
        public void VerifyContentTypeTest(Method method)
        {
            var handler = new ConfigurationServiceManager();
            var request = new Dictionary <string, string>(DefaultParameters);
            ApiResponse <object> response = null;

            if (method == Method.Create)
            {
                response = handler.ConfigurationService <object>(request["service"], request["id"], request["body"], System.Net.Http.HttpMethod.Put);
            }
            else
            {
                response = handler.ConfigurationService <object>(request["service"], request["id"], System.Net.Http.HttpMethod.Get);
            }

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.ContentType, PrIs.Not.Null);
            PrAssert.That(response.ContentType.MediaType, method == Method.Get ? PrIs.EqualTo("application/json") : PrIs.EqualTo("text/html"));
        }
コード例 #11
0
        public void InvalidHeaderTest(InvalidHeader inputType, Method method)
        {
            ConfigurationServiceManager handler = null;

            if (inputType == InvalidHeader.Missing)
            {
                handler = new ConfigurationServiceManager(null, null);
            }
            else
            {
                var identityHeader = inputType == InvalidHeader.HeaderIsLowerCase ? "x-identity" : "X-IDENTITY";
                handler = new ConfigurationServiceManager(identityHeader, InvalidServiceContentMapping[inputType]);

                if (inputType == InvalidHeader.AddOneMoreHeaderWithValidService || inputType == InvalidHeader.AddOneMoreHeaderWithInalidService)
                {
                    handler.AddHeader("X-IDENTITY-123", InvalidServiceContentMapping[inputType]);
                }
            }

            PrAssert.That(Response(handler, method), PrIs.ErrorResponse());
        }
コード例 #12
0
        public void ValidHeaderTest(ValidHeader inputType, Method method)
        {
            var handler = new ConfigurationServiceManager("X-IDENTITY", ServiceContentMapping[inputType]);

            PrAssert.That(Response(handler, method), PrIs.SuccessfulResponse());
        }