Esempio n. 1
0
        private void btnSubmitRest_Click(object sender, RoutedEventArgs e)
        {
            var request = new RESTRequest
            {
                EndPoint    = txtboxUrlRest.Text + txtboxParams.Text,
                Method      = dropdownMethod.Text,
                PostData    = txtboxRestRequest.Text,
                ContentType = contentTypeList.Text,
            };

            var test = TestsController.GetRESTResponse(request, User);

            txtboxRestResponse.Text  = test.Response;
            timeProcessing_Rest.Text = test.ProcessingTime.ToString();

            if (!string.IsNullOrWhiteSpace(key1rest.Text) && (!string.IsNullOrWhiteSpace(value1rest.Text)))
            {
                var validare = TestsController.ValidateResponseREST(key1rest.Text, value1rest.Text, test.Response);
                if (validare == 1)
                {
                    assert1rest.Background = System.Windows.Media.Brushes.Green;
                }
                else if (validare == 0)
                {
                    assert1rest.Background = System.Windows.Media.Brushes.Red;
                }
                else
                {
                    assert1rest.Background = System.Windows.Media.Brushes.Yellow;
                }
            }
            ;
            if (!string.IsNullOrWhiteSpace(key2rest.Text) && (!string.IsNullOrWhiteSpace(value2rest.Text)))
            {
                var validare = TestsController.ValidateResponseREST(key2rest.Text, value2rest.Text, test.Response);
                if (validare == 1)
                {
                    assert2rest.Background = System.Windows.Media.Brushes.Green;
                }
                else if (validare == 0)
                {
                    assert2rest.Background = System.Windows.Media.Brushes.Red;
                }
                else
                {
                    assert2rest.Background = System.Windows.Media.Brushes.Yellow;
                }
            }
        }