コード例 #1
0
        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);
        }
コード例 #2
0
            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.");
                }
            }
コード例 #3
0
        private static bool Validate404Response(ZumoTest test, MobileServiceInvalidOperationException msioe)
        {
            test.AddLog("Received expected exception - {0}: {1}", msioe.GetType().FullName, msioe.Message);
            var response = msioe.Response;

            if (response.StatusCode == 404)
            {
                test.AddLog("And error code is the expected one.");
                return(true);
            }
            else
            {
                test.AddLog("Received error code is not the expected one: {0} - {1}", response.StatusCode, response.StatusDescription);
                return(false);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        private void lstTests_DoubleTapped_1(object sender, DoubleTappedRoutedEventArgs e)
        {
            int selectedGroup = this.lstTestGroups.SelectedIndex;

            if (selectedGroup >= 0)
            {
                ZumoTestGroup   testGroup    = allTests[selectedGroup];
                int             selectedTest = this.lstTests.SelectedIndex;
                List <ZumoTest> tests        = testGroup.AllTests.ToList();
                if (selectedTest >= 0 && selectedTest < tests.Count)
                {
                    ZumoTest      test  = tests[selectedTest];
                    List <string> lines = new List <string>();
                    lines.Add(string.Format("Logs for test {0} (status = {1})", test.Name, test.Status));
                    lines.AddRange(test.GetLogs());
                    lines.Add("-----------------------");

                    UploadLogsControl uploadLogsPage = new UploadLogsControl(testGroup.Name, string.Join("\n", lines), null);
                    uploadLogsPage.Display();
                }
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 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);
             }
         }
     }
 }
コード例 #8
0
 public ListViewForTest(int index, ZumoTest test)
 {
     this.index              = index;
     this.test               = test;
     test.TestStatusChanged += test_TestStatusChanged;
 }
コード例 #9
0
 public ConflictResolvingSyncHandler(ZumoTest test, IMobileServiceClient client, ConflictResolution resolutionPolicy)
 {
     this.test               = test;
     this.client             = client;
     this.conflictResolution = resolutionPolicy;
 }
コード例 #10
0
 public AbortingSyncHandler(ZumoTest test, Func <string, bool> shouldAbortForId)
 {
     this.test           = test;
     this.AbortCondition = shouldAbortForId;
 }