Skip to content

Commit ee89875

Browse files
author
Bernt Røskar Brenna
committed
Fixed typo: requestCreator -> responseCreator
If response creator file is script, add line numbers.
1 parent 9cbb96a commit ee89875

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

netmockery/Controllers/EndpointsController.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,24 @@ public ActionResult EndpointJsonFile(string name)
9595
return Content(System.IO.File.ReadAllText(System.IO.Path.Combine(endpoint.Directory, "endpoint.json")));
9696
}
9797

98-
public ActionResult ViewRequestCreatorFile(string name, int requestCreatorId)
98+
public ActionResult ViewResponseCreatorFile(string name, int responseCreatorId)
9999
{
100100
var endpoint = _endpointCollection.Get(name);
101-
var requestCreator = endpoint.Responses.ElementAt(requestCreatorId).Item2;
102-
if (requestCreator is FileDynamicResponseCreator fileDynamicResponseCreator)
101+
var responseCreator = endpoint.Responses.ElementAt(responseCreatorId).Item2;
102+
if (responseCreator is FileDynamicResponseCreator fileDynamicResponseCreator)
103103
{
104-
return Content(fileDynamicResponseCreator.GetSourceCodeWithIncludesExecuted(), "text/plain");
104+
var sourceCode = fileDynamicResponseCreator.GetSourceCodeWithIncludesExecuted();
105+
var lines = sourceCode.Split('\n');
106+
var sourceWithLineNumber =
107+
from
108+
i in Enumerable.Range(0, lines.Length)
109+
select
110+
$"{i + 1}: {lines[i]}";
111+
return Content(string.Join("\n", sourceWithLineNumber), "text/plain");
105112
}
106-
else if (requestCreator is IResponseCreatorWithFilename requestCreatorWithFilename)
113+
else if (responseCreator is IResponseCreatorWithFilename responseCreatorWithFilename)
107114
{
108-
return File(System.IO.File.OpenRead(requestCreatorWithFilename.Filename), "text/plain");
115+
return File(System.IO.File.OpenRead(responseCreatorWithFilename.Filename), "text/plain");
109116
}
110117
else
111118
{

netmockery/Views/Shared/Components/ResponseCreator/FileDynamicResponseCreator.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@using netmockery
22
@model FileDynamicResponseCreator
33
Script:
4-
<a href="@Url.Action("ViewRequestCreatorFile", "Endpoints", new { name = (string)ViewData["endpointName"], requestCreatorId = (int)ViewData["index"] })">
4+
<a href="@Url.Action("ViewResponseCreatorFile", "Endpoints", new { name = (string)ViewData["endpointName"], responseCreatorId = (int)ViewData["index"] })">
55
<code>@System.IO.Path.GetFileName(Model.Filename)</code>
66
</a>
77

netmockery/Views/Shared/Components/ResponseCreator/FileResponse.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@using netmockery
22
@model FileResponse
33
From file:
4-
<a href="@Url.Action("ViewRequestCreatorFile", "Endpoints", new { name = (string)ViewData["endpointName"], requestCreatorId = (int)ViewData["index"] })">
4+
<a href="@Url.Action("ViewResponseCreatorFile", "Endpoints", new { name = (string)ViewData["endpointName"], responseCreatorId = (int)ViewData["index"] })">
55
<code>@System.IO.Path.GetFileName(Model.Filename)</code>
66
</a>
77

0 commit comments

Comments
 (0)