Tests: Cover test for FrmError.
This commit is contained in:
@@ -72,7 +72,7 @@ public class FakeWebContext : IWebContext
|
||||
|
||||
public void PrepareUncacheableResponse()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// TODO: Mark as Uncacheable response
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ public class FrmEchoTests
|
||||
string result = fakeWebContext.FakeWritePackages.ToString("");
|
||||
Assert.Equal(
|
||||
expected: """
|
||||
<pre><code>Header:{ }
|
||||
<pre><code>
|
||||
Header:{ }
|
||||
Query:{ }
|
||||
Form:{ }
|
||||
</code></pre>
|
||||
@@ -37,7 +38,8 @@ public class FrmEchoTests
|
||||
string result = fakeWebContext.FakeWritePackages.ToString("");
|
||||
Assert.Equal(
|
||||
expected: """
|
||||
<pre><code>Header:{ }
|
||||
<pre><code>
|
||||
Header:{ }
|
||||
Query:{ "Test": "Value" }
|
||||
Form:{ }
|
||||
</code></pre>
|
||||
@@ -57,7 +59,8 @@ public class FrmEchoTests
|
||||
string result = fakeWebContext.FakeWritePackages.ToString("");
|
||||
Assert.Equal(
|
||||
expected: """
|
||||
<pre><code>Header:{ }
|
||||
<pre><code>
|
||||
Header:{ }
|
||||
Query:{ }
|
||||
Form:{ "Test": "Value" }
|
||||
</code></pre>
|
||||
|
||||
28
VAR.WebFormsCore.Tests/Pages/FrmErrorTests.cs
Normal file
28
VAR.WebFormsCore.Tests/Pages/FrmErrorTests.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using VAR.WebFormsCore.Pages;
|
||||
using VAR.WebFormsCore.Tests.Fakes;
|
||||
using Xunit;
|
||||
|
||||
namespace VAR.WebFormsCore.Tests.Pages;
|
||||
|
||||
public class FrmErrorTests
|
||||
{
|
||||
[Fact]
|
||||
public void ProcessRequest__TestException()
|
||||
{
|
||||
FakeWebContext fakeWebContext = new();
|
||||
FrmError frmError = new(new Exception("Test"));
|
||||
|
||||
frmError.ProcessRequest(fakeWebContext);
|
||||
|
||||
string result = fakeWebContext.FakeWritePackages.ToString("");
|
||||
Assert.Equal(
|
||||
expected: """
|
||||
<!DOCTYPE html>
|
||||
<html ><head ><title>Application Error</title><meta content="IE=Edge" http-equiv="X-UA-Compatible" /><meta content="text/html; charset=utf-8" http-equiv="content-type" /><meta name="author" /><meta name="Copyright" /><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=4, user-scalable=1" /><script type="text/javascript" src="ScriptsBundler?v=1.0.0.0"></script>
|
||||
<link href="StylesBundler?v=1.0.0.0" type="text/css" rel="stylesheet"/>
|
||||
</head><body ><form id="formMain" name="formMain" method="post" action="FrmError"><div class="divHeader"><a href="."><h1 ></h1></a><input type="submit" id="ctl00_btnPostback" name="ctl00_btnPostback" class="button" style="display: none;" value="Postback"></input><div class="divUserInfo"></div></div><div class="divContent"><h2 >Application Error</h2><p><b>Message:</b> Test</p><p><b>Stacktrace:</b></p><div class="divCode"><pre><code></code></pre></div></div></form></body></html>
|
||||
""",
|
||||
actual: result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class FrmEcho : IHttpHandler
|
||||
public void ProcessRequest(IWebContext context)
|
||||
{
|
||||
context.ResponseContentType = "text/html";
|
||||
context.ResponseWrite("<pre><code>");
|
||||
context.ResponseWrite("<pre><code>\n");
|
||||
context.ResponseWrite($"Header:{JsonWriter.WriteObject(context.RequestHeader, indent: true)}\n");
|
||||
context.ResponseWrite($"Query:{JsonWriter.WriteObject(context.RequestQuery, indent: true)}\n");
|
||||
context.ResponseWrite($"Form:{JsonWriter.WriteObject(context.RequestForm, indent: true)}\n");
|
||||
|
||||
Reference in New Issue
Block a user