예제 #1
0
        public void GetRestRequest_IfJsonSerializerIsNotSet_ReturnsRequestWithDefaultSerializer(RestClientParameters restClientParameters)
        {
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            Assert.Null(result.JsonSerializer);
            Assert.Null(result.XmlSerializer);
        }
예제 #2
0
        public void GetRestRequest_IfDataFormatDoesNotExist_ThrowsException(
            DataFormat format)
        {
            var restClientParameters = new RestClientParameters {
                RequestDataFormat = format
            };
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            Assert.Catch(() => restClientWrapper.GetRestRequest(restClientParameters));
        }
예제 #3
0
        public void GetRestRequest_IfJsonSerializerIsSet_ReturnsRequestWithCustomSerializer(RestClientParameters restClientParameters)
        {
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            Assert.AreEqual(RestSharp.DataFormat.Json, result.RequestFormat);
            Assert.AreEqual(restClientParameters.RequestDataSerializer, result.JsonSerializer);
            Assert.Null(result.XmlSerializer);
        }
예제 #4
0
        public void GetRestRequest_IfDataFormatExists_ReturnsRequestWithCorrectRequestFormat(
            RestClientParameters restClientParameters,
            RestSharp.DataFormat expectedFormat)
        {
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            Assert.AreEqual(expectedFormat, result.RequestFormat);
        }
예제 #5
0
        public void GetRestRequest_IfRequestMethodDoesNotExist_ThrowsException(
            RequestMethod method)
        {
            var restClientParameters = new RestClientParameters {
                RequestMethod = method
            };
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            Assert.Catch(() => restClientWrapper.GetRestRequest(restClientParameters));
        }
예제 #6
0
        public void GetRestRequest_IfRequestMethodExists_ReturnsRequestWithCorrectMethod(
            RestClientParameters restClientParameters,
            Method expectedMethod)
        {
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            Assert.AreEqual(expectedMethod, result.Method);
        }
예제 #7
0
        public void GetRestRequest_ReturnsRequestWithCorrectUrl(string url, string expectedResource)
        {
            var restClientParameters = new RestClientParameters {
                RequestUrl = url,
            };
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            Assert.AreEqual(expectedResource, result.Resource);
        }
예제 #8
0
        public void GetRestRequest_ReturnsRequestWithCorrectBody(
            RestClientParameters restClientParameters,
            string expectedBodyType)
        {
            var expectedBodyCount = restClientParameters.RequestBody != null ? 1 : 0;
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            var body = result.Parameters.Where(x => x.Type == ParameterType.RequestBody);

            Assert.AreEqual(expectedBodyCount, body.Count());
            Assert.AreEqual(expectedBodyType, body.FirstOrDefault()?.ContentType);
        }
예제 #9
0
        public void GetRestRequest_ReturnsRequestWithCorrectQueryParams(RestClientParameters restClientParameters)
        {
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            var result = restClientWrapper.GetRestRequest(restClientParameters);

            var parameters    = result.Parameters.Where(x => x.Type == ParameterType.QueryString);
            var expectedCount = restClientParameters.RequestQueryParameters?.Count ?? 0;

            Assert.AreEqual(expectedCount, parameters.Count());
            if (expectedCount <= 0)
            {
                return;
            }

            foreach (var keyValue in restClientParameters.RequestQueryParameters)
            {
                var requestParameter = parameters.FirstOrDefault(x => x.Name == keyValue.Key);
                Assert.NotNull(requestParameter);
                Assert.AreEqual(keyValue.Value, requestParameter.Value);
            }
        }
예제 #10
0
        public void GetRestRequest_IfParametersIsNull_ThrowsException()
        {
            var restClientWrapper = new SDK.Utilities.RestClientWrapper.RestClientWrapper();

            Assert.Catch(() => restClientWrapper.GetRestRequest(null));
        }