Beispiel #1
0
        public async Task CallIntArrayParamAPI_Post_GetResponseWithParamatersNameValueAppended()
        {
            #region Arrange

            var resourceURL = @"/api/user/PostIntArrayStringResponse";
            var restHelper  = new EcSolvo.RestHelper(_BaseAddress);

            var ParameterKey   = "ArrayObject";
            var ParameterArray = new int[] { 2, 3, 4 };

            string result;
            #endregion

            #region Act
            using (WebApp.Start <WebApiStartup>(_BaseAddress))
            {
                restHelper.AssignMessageBodyParameter(ParameterArray);
                result = await restHelper.ExecuteAsync <string>(HttpMethod.Post, resourceURL);
            }


            #endregion

            #region Assert
            Assert.AreEqual <string>(string.Format("{0}-{1},{2},{3}",
                                                   ParameterKey, ParameterArray[0],
                                                   ParameterArray[1], ParameterArray[2]
                                                   ), result);
            #endregion
        }
Beispiel #2
0
        public async Task CallNestedComplexRefTypeParamAPI_Post_GetResponseWithParamatersNameValueAppended()
        {
            #region Arrange
            var resourceURL = "api/user/PostNestedComplexReferenceTypeParamStringResponse";
            var restHelper  = new EcSolvo.RestHelper(_BaseAddress);

            string ParameterKey1     = "VariableStr";
            string ParameterValueStr = "Jia";

            string ParameterKey2     = "VariableInt";
            int    ParameterValueInt = 1;

            string ParameterKey3      = "VariableBool";
            bool   ParameterValueBool = true;

            string   ParameterKey4          = "VariableDateTime";
            DateTime ParameterValueDateTime = DateTime.Now;

            string ParameterKey5          = "OuterVariableStr";
            string OuterParameterValueStr = "Outer";

            ComplexRefType ParameterComplexRefType = new ComplexRefType()
            {
                VariableBool     = ParameterValueBool,
                VariableDateTime = ParameterValueDateTime,
                VariableInt      = ParameterValueInt,
                VariableStr      = ParameterValueStr
            };

            NestedComplexRefType ParameterNestedComplexRefType = new NestedComplexRefType()
            {
                InnerVariableComplex = ParameterComplexRefType,
                OuterVariableStr     = OuterParameterValueStr
            };
            string result;
            #endregion

            #region Act
            using (WebApp.Start <WebApiStartup>(_BaseAddress))
            {
                restHelper.AssignMessageBodyParameter(ParameterNestedComplexRefType);
                result = await restHelper.ExecuteAsync <string>(HttpMethod.Post, resourceURL);
            }
            #endregion

            #region Assert
            Assert.AreEqual <string>(string.Format("{0}={1}&{2}={3}&{4}={5}&{6}={7}&{8}={9}",
                                                   ParameterKey5, OuterParameterValueStr,
                                                   ParameterKey1, ParameterValueStr,
                                                   ParameterKey2, ParameterValueInt,
                                                   ParameterKey3, ParameterValueBool,
                                                   ParameterKey4, ParameterValueDateTime), result);
            #endregion
        }
Beispiel #3
0
        public async Task CallComplexArrayParamAPI_Post_GetResponseWithParamatersNameValueAppended()
        {
            #region Arrange

            var resourceURL = @"/api/user/PostComplexArrayStringResponse";
            var restHelper  = new EcSolvo.RestHelper(_BaseAddress);

            var      ParameterKey      = "ArrayObject";
            bool     ParameterBool     = true;
            int      ParameterInt      = 2;
            DateTime ParameterDateTime = DateTime.Now;
            string   ParameterStr      = "Jia";
            var      ParameterArray    = new ComplexRefType[] {
                new ComplexRefType()
                {
                    VariableBool = ParameterBool, VariableDateTime = ParameterDateTime, VariableInt = ParameterInt, VariableStr = ParameterStr
                },
                new ComplexRefType()
                {
                    VariableBool = ParameterBool, VariableDateTime = ParameterDateTime, VariableInt = ParameterInt, VariableStr = ParameterStr
                },
                new ComplexRefType()
                {
                    VariableBool = ParameterBool, VariableDateTime = ParameterDateTime, VariableInt = ParameterInt, VariableStr = ParameterStr
                }
            };

            string result;
            #endregion

            #region Act
            using (WebApp.Start <WebApiStartup>(_BaseAddress))
            {
                restHelper.AssignMessageBodyParameter(ParameterArray);
                result = await restHelper.ExecuteAsync <string>(HttpMethod.Post, resourceURL);
            }


            #endregion

            #region Assert
            Assert.AreEqual <string>(string.Format("{0}-{1},{2},{3}",
                                                   ParameterKey, ParameterArray[0].VariableBool,
                                                   ParameterArray[1].VariableBool, ParameterArray[2].VariableBool
                                                   ), result);
            #endregion
        }
Beispiel #4
0
        public async Task CallSingleParamAPI_Post_GetResponseWithParamaterNameValueAppended()
        {
            #region Arrange
            var    resourceURL = "api/user/PostDateTimeParamStringResponse";
            var    restHelper  = new EcSolvo.RestHelper(_BaseAddress);
            string Parameter   = "Dummy";
            string result;
            #endregion

            #region Act
            using (WebApp.Start <WebApiStartup>(_BaseAddress))
            {
                restHelper.AssignMessageBodyParameter(Parameter);
                result = await restHelper.ExecuteAsync <string>(HttpMethod.Post, resourceURL);
            }
            #endregion

            #region Assert
            Assert.AreEqual <string>(Parameter, result);
            #endregion
        }