Beispiel #1
0
        public async Task <Dictionary <string, bool> > GetRuntimeFeatures(ZumoTest test)
        {
            if (runtimeFeatures == null)
            {
                RuntimeType     = "unknown";
                RuntimeVersion  = "unknown";
                IsNetRuntime    = false;
                IsNHPushEnabled = false;

                try
                {
                    JToken apiResult = await Client.InvokeApiAsync("runtimeInfo", HttpMethod.Get, null);

                    runtimeFeatures = apiResult["features"].ToObject <Dictionary <string, bool> >();
                    var runtimeInfo = apiResult["runtime"].ToObject <Dictionary <string, string> >();
                    RuntimeType    = runtimeInfo["type"];
                    RuntimeVersion = runtimeInfo["version"];

                    IsNetRuntime    = RuntimeType.Equals(".NET");
                    IsNHPushEnabled = runtimeFeatures[ZumoTestGlobals.RuntimeFeatureNames.NH_PUSH_ENABLED];
                }
                catch (Exception ex)
                {
                    test.AddLog(ex.Message);
                }

                if (runtimeFeatures.Count > 0)
                {
                    test.AddLog("Runtime: {0}", ZumoTestGlobals.Instance.RuntimeType);
                    test.AddLog("Version: {0}", ZumoTestGlobals.Instance.RuntimeVersion);
                    foreach (var entry in runtimeFeatures)
                    {
                        test.AddLog("Runtime feature: {0} : {1}", entry.Key, entry.Value);
                    }
                }
                else
                {
                    test.AddLog("Could not load the runtime information");
                }
            }

            return(runtimeFeatures);
        }
        public async Task<Dictionary<string, bool>> GetRuntimeFeatures(ZumoTest test)
        {
            if (runtimeFeatures == null)
            {
                RuntimeType = "unknown";
                RuntimeVersion = "unknown";
                IsNetRuntime = false;
                IsNHPushEnabled = false;

                try
                {
                    JToken apiResult = await Client.InvokeApiAsync("runtimeInfo", HttpMethod.Get, null);
                    runtimeFeatures = apiResult["features"].ToObject<Dictionary<string, bool>>();
                    var runtimeInfo = apiResult["runtime"].ToObject<Dictionary<string, string>>();
                    RuntimeType = runtimeInfo["type"];
                    RuntimeVersion = runtimeInfo["version"];

                    IsNetRuntime = RuntimeType.Equals(".NET");
                    IsNHPushEnabled = runtimeFeatures[ZumoTestGlobals.RuntimeFeatureNames.NH_PUSH_ENABLED];
                }
                catch (Exception ex)
                {
                    test.AddLog(ex.Message);
                }

                if (runtimeFeatures.Count > 0)
                {
                    test.AddLog("Runtime: {0}", ZumoTestGlobals.Instance.RuntimeType);
                    test.AddLog("Version: {0}", ZumoTestGlobals.Instance.RuntimeVersion);
                    foreach (var entry in runtimeFeatures)
                    {
                        test.AddLog("Runtime feature: {0} : {1}", entry.Key, entry.Value);
                    }
                }
                else
                {
                    test.AddLog("Could not load the runtime information");
                }
            }

            return runtimeFeatures;
        }
 public void AddTest(ZumoTest test)
 {
     this.tests.Add(test);
 }
        private static bool ValidateResponseHeader(ZumoTest test, HttpStatusCode expectedStatus, Dictionary<string, string> expectedHeaders, HttpResponseMessage response)
        {
            bool result = true;
            if (expectedStatus != response.StatusCode)
            {
                test.AddLog("Error in response status: expected {0}, received {1}", expectedStatus, response.StatusCode);
                result = false;
            }
            else
            {
                foreach (var reqHeader in expectedHeaders.Keys)
                {
                    IEnumerable<string> headerValue;
                    if (!response.Headers.TryGetValues(reqHeader, out headerValue))
                    {
                        test.AddLog("Error, expected header {0} not found", reqHeader);
                        result = false;
                        break;
                    }
                    else
                    {
                        if (!expectedHeaders[reqHeader].Equals(headerValue.FirstOrDefault()))
                        {
                            test.AddLog("Error, header value for {0} is incorrect. Expected {1}, actual {2}",
                                reqHeader, expectedHeaders[reqHeader], headerValue.FirstOrDefault() ?? "<<NULL>>");
                            result = false;
                            break;
                        }
                    }
                }
            }

            return result;
        }
Beispiel #5
0
 public void AddTest(ZumoTest test)
 {
     this.tests.Add(test);
 }
 private static bool ValidateExpectedError(ZumoTest test, MobileServiceInvalidOperationException exception, bool operationShouldSucceed)
 {
     if (operationShouldSucceed)
     {
         if (exception != null)
         {
             test.AddLog("Operation should have succeeded, but it failed: {0}", exception);
             return false;
         }
         else
         {
             return true;
         }
     }
     else
     {
         if (exception == null)
         {
             test.AddLog("Operation should have failed, but it succeeded.");
             return false;
         }
         else
         {
             if (exception.Response.StatusCode == HttpStatusCode.Unauthorized ||
                 exception.Response.StatusCode == HttpStatusCode.Forbidden)
             {
                 test.AddLog("Expected exception thrown, with expected status code.");
                 return true;
             }
             else
             {
                 test.AddLog("Expected exception was thrown, but with invalid status code: {0}", exception.Response.StatusCode);
                 return false;
             }
         }
     }
 }
            public HandlerWithMultipleRequests(ZumoTest test, int numberOfRequests)
            {
                this.test = test;
                this.NumberOfRequests = numberOfRequests;
                this.TestFailed = false;

                if (numberOfRequests < 1)
                {
                    throw new ArgumentOutOfRangeException("numberOfRequests", "Number of requests must be at least 1.");
                }
            }
        private static bool ValidateParameters(ZumoTest test, string operation, JObject expected, JObject actual)
        {
            test.AddLog("Called {0}, now validating parameters", operation);
            List<string> errors = new List<string>();
            if (!Util.CompareJson(expected, actual, errors))
            {
                foreach (var error in errors)
                {
                    test.AddLog(error);
                }

                test.AddLog("Parameters passing for the {0} operation failed", operation);
                test.AddLog("Expected: {0}", expected);
                test.AddLog("Actual: {0}", actual);
                return false;
            }
            else
            {
                test.AddLog("Parameters passing for the {0} operation succeeded", operation);
                return true;
            }
        }
        static async Task WaitForChannelUriAssignment(ZumoTest test, HttpNotificationChannel pushChannel, TimeSpan maxWait)
        {
            DateTime start = DateTime.UtcNow;
            while (DateTime.UtcNow.Subtract(start) < maxWait)
            {
                if (pushChannel.ConnectionStatus == ChannelConnectionStatus.Connected && pushChannel.ChannelUri != null)
                {
                    test.AddLog("Channel URI: {0}", pushChannel.ChannelUri);
                    break;
                }
                else
                {
                    test.AddLog("Waiting for the push channel URI to be assigned");
                }

                await Util.TaskDelay(500);
            }
        }
 public ListViewForTest(int index, ZumoTest test)
 {
     this.index = index;
     this.test = test;
     test.TestStatusChanged += test_TestStatusChanged;
 }