Exemplo n.º 1
0
        public TestTankClient(DynObject startResponse, TankAction expectedAction, DynObject takeActionResponse = null)
        {
            this.expectedAction = expectedAction;
            this.startResponse  = startResponse;

            if (takeActionResponse == null)
            {
                takeActionResponse = DynObject.Parse(@"{
                    'status': 'won',
                    'health': 200,
                    'energy': 10,
                    'orientation': 'north',
                    'grid': '________________________
___W_____WWWWWWWW_______
___W_W__________________
___W_W_______B__________
___W_W__________________
___W_W__________________
_WWWWWWWWW___L____O_____
_____W__________________
_____W_WWWWW____________
_________WWWWWWWW_______
________________________
___________WWWW_________
__X_____________________
________________________
____WWW_________________
________________________'
                }");
            }

            this.takeActionResponse = takeActionResponse;
        }
Exemplo n.º 2
0
 private void AddObject(string name, string value, DynObject serialization)
 {
     if (value != null && value.Length > 0)
     {
         if (value[0] == '{')
         {
             serialization[name] = DynObject.Parse(value);
         }
         else
         {
             serialization[name] = value;
         }
     }
 }
Exemplo n.º 3
0
        public DynObject GetBody()
        {
            if (body == null)
            {
                using (StreamReader reader = new StreamReader(baseRequest.InputStream, IOUtil.Utf8Encoding))
                {
                    string bodyText = reader.ReadToEnd();
                    if (bodyText == null || bodyText.Length == 0)
                    {
                        bodyText = "{}";
                    }

                    body = DynObject.Parse(bodyText);
                }
            }

            return(body);
        }
Exemplo n.º 4
0
        public dynamic GetJsonResponse(string resource, string method = "GET", string body = null, Dictionary <string, string> headers = null, HttpStatusCode expectedStatus = HttpStatusCode.OK)
        {
            string responseText = GetTextResponse(resource, method, body, headers, expectedStatus);

            if (responseText.Length > 0)
            {
                if (responseText[0] == '{')
                {
                    return(DynObject.Parse(responseText));
                }
                else
                {
                    return(DynArray.Parse(responseText));
                }
            }
            else
            {
                return(null);
            }
        }