public void ResponseLogTest3() { if (MvcApplication.RequestLog.Rows.Count == 0) { ResponseLogTest2();//put some rows if not any detected... } Models.MathResponse mr = MvcApplication.RequestLog.Rows[0].ItemArray.ToMathResponse(); Assert.IsNotNull(mr, "The extension method should not have returned a null MathResponse object"); }
public void ResponseLogTest2() { Models.MathResponse mr = new Models.MathResponse { UserQuery = 0, Response = 0, RequestOrigin = "TEST" }; mr.LogRequest(); mr = new Models.MathResponse { UserQuery = 1, Response = 1, RequestOrigin = "TEST2" }; mr.LogRequest(); Assert.IsTrue(MvcApplication.RequestLog.Rows.Count > 0, "After logging a request, the datatable should have rows in it"); }
/// <summary> /// GET: /Fibonacci/8 /// </summary> /// <param name="input"></param> /// <returns></returns> public ActionResult Compute(long input) { try { MathResponse mr = new Models.MathResponse(); mr.CaptureOrigin(this); mr.UserQuery = input; mr.Response = bkwdesign.math.fibonacci.GetNthNumber(input); mr.LogRequest(); //extn. method return(View(mr)); } catch (InvalidOperationException ex) { return(View("Error", ex)); } }
public ActionResult Compute(Models.MathResponse mr) { //although this works... //return Compute(mr.UserQuery); return(RedirectToAction("Compute", new { input = mr.UserQuery }));//in this case, I prefer nice route to show in address bar }