public JsonResult GritTestJsonData()
        {
            TestJsonResult json0 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };
            TestJsonResult json1 = new TestJsonResult {
                Id = 2, Name = "Czechy", Age = 14, DataUrodzin = new DateTime(2009, 10, 06)
            };
            TestJsonResult json2 = new TestJsonResult {
                Id = 3, Name = "Włochy", Age = 15, DataUrodzin = new DateTime(2005, 10, 06)
            };
            TestJsonResult json3 = new TestJsonResult {
                Id = 4, Name = "Jamaica", Age = 18, DataUrodzin = new DateTime(2000, 01, 01)
            };
            TestJsonResult json4 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };
            TestJsonResult json5 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };
            TestJsonResult json6 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };
            TestJsonResult json7 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };
            TestJsonResult json8 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };
            TestJsonResult json9 = new TestJsonResult {
                Id = 1, Name = "Włochy", Age = 12, DataUrodzin = new DateTime(2010, 10, 05)
            };


            return(Json(new List <TestJsonResult> {
                json0, json1, json2, json3, json4, json5, json6, json7, json8, json9
            }, JsonRequestBehavior.AllowGet));
        }
 public JsonResult DeleteItem(TestJsonResult temp)
 {
     return(Json(temp, JsonRequestBehavior.AllowGet));
 }
Esempio n. 3
0
            public TestResult Process(RequestResult result, string uri)
            {
                TestResult testResult = null;

                if (result.ActionExecutedContext != null && result.ActionExecutedContext.Exception != null)
                {
                    return new TestErrorResult(uri, result.ResponseText)
                           {
                               Exception = result.ActionExecutedContext.Exception
                           }
                }
                ;

                var emptyResult = result.ActionExecutedContext != null ? result.ActionExecutedContext.Result as EmsgEmptyResult : null;

                if (emptyResult != null)
                {
                    testResult = new TestEmptyResult(uri, result.ResponseText);
                }

                var viewResult = result.ActionExecutedContext != null ? result.ActionExecutedContext.Result as ViewResult : null;

                if (viewResult != null)
                {
                    testResult = new TestViewResult(uri, result.ResponseText, viewResult.Model, viewResult.ViewData.ModelState);
                }

                var jsonResult = result.ActionExecutedContext != null ? result.ActionExecutedContext.Result as JsonResult : null;

                if (jsonResult != null)
                {
                    testResult = new TestJsonResult(uri, result.ResponseText, jsonResult.Data);
                }

                var partialViewResult = result.ActionExecutedContext != null ? result.ActionExecutedContext.Result as PartialViewResult : null;

                if (partialViewResult != null)
                {
                    testResult = new TestPartialViewResult(uri, result.ResponseText, partialViewResult.Model, partialViewResult.ViewData.ModelState);
                }

                var fileContentResult = result.ActionExecutedContext != null ? result.ActionExecutedContext.Result as FileContentResult : null;

                if (fileContentResult != null)
                {
                    testResult = new TestFileContentResult(uri, result.ResponseText, fileContentResult.FileContents, fileContentResult.ContentType, fileContentResult.FileDownloadName);
                }

                var redirectResult = result.ResultExecutedContext != null ? result.ResultExecutedContext.Result as RedirectResult : null;

                if (redirectResult != null)
                {
                    testResult = new TestRedirectResult(uri, result.ResponseText, redirectResult.Url);
                }

                var redirectToRouteResult = result.ResultExecutedContext != null ? result.ResultExecutedContext.Result as RedirectToRouteResult : null;

                if (redirectToRouteResult != null)
                {
                    testResult = new TestRedirectToRouteResult(uri, result.ResponseText, redirectToRouteResult.RouteValues.ToDictionary(k => k.Key, v => v.Value));
                }

                if (result.Response != null && result.Response.StatusCode == 401) // Unauthorized
                {
                    testResult = new TestHttpUnauthorizedResult(uri);
                }

                if (result.Response != null && result.Response.StatusCode == 404) // Unauthorized
                {
                    testResult = new TestHttpNotFoundResult(uri);
                }

                if (testResult == null)
                {
                    testResult = new TestErrorResult(uri, result.ResponseText);
                }

                //ToDo: PermissionKey
                //if (result.ActionExecutedContext != null)
                //    testResult.Permission = (Permission?)result.ActionExecutedContext.HttpContext.Items["PermissionKey"] ?? Permission.None;
                //else if (result.ResultExecutedContext != null)
                //    testResult.Permission = (Permission?)result.ResultExecutedContext.HttpContext.Items["PermissionKey"] ?? Permission.None;

                return(testResult);
            }
        }