From ee89875b7e0e4b5351c14a08fb5598b66dbeca76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernt=20R=C3=B8skar=20Brenna?= Date: Sat, 2 Sep 2017 13:11:06 +0200 Subject: [PATCH] Fixed typo: requestCreator -> responseCreator If response creator file is script, add line numbers. --- netmockery/Controllers/EndpointsController.cs | 19 +++++++++++++------ .../FileDynamicResponseCreator.cshtml | 2 +- .../ResponseCreator/FileResponse.cshtml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/netmockery/Controllers/EndpointsController.cs b/netmockery/Controllers/EndpointsController.cs index ca3697f..367d825 100644 --- a/netmockery/Controllers/EndpointsController.cs +++ b/netmockery/Controllers/EndpointsController.cs @@ -95,17 +95,24 @@ public ActionResult EndpointJsonFile(string name) return Content(System.IO.File.ReadAllText(System.IO.Path.Combine(endpoint.Directory, "endpoint.json"))); } - public ActionResult ViewRequestCreatorFile(string name, int requestCreatorId) + public ActionResult ViewResponseCreatorFile(string name, int responseCreatorId) { var endpoint = _endpointCollection.Get(name); - var requestCreator = endpoint.Responses.ElementAt(requestCreatorId).Item2; - if (requestCreator is FileDynamicResponseCreator fileDynamicResponseCreator) + var responseCreator = endpoint.Responses.ElementAt(responseCreatorId).Item2; + if (responseCreator is FileDynamicResponseCreator fileDynamicResponseCreator) { - return Content(fileDynamicResponseCreator.GetSourceCodeWithIncludesExecuted(), "text/plain"); + var sourceCode = fileDynamicResponseCreator.GetSourceCodeWithIncludesExecuted(); + var lines = sourceCode.Split('\n'); + var sourceWithLineNumber = + from + i in Enumerable.Range(0, lines.Length) + select + $"{i + 1}: {lines[i]}"; + return Content(string.Join("\n", sourceWithLineNumber), "text/plain"); } - else if (requestCreator is IResponseCreatorWithFilename requestCreatorWithFilename) + else if (responseCreator is IResponseCreatorWithFilename responseCreatorWithFilename) { - return File(System.IO.File.OpenRead(requestCreatorWithFilename.Filename), "text/plain"); + return File(System.IO.File.OpenRead(responseCreatorWithFilename.Filename), "text/plain"); } else { diff --git a/netmockery/Views/Shared/Components/ResponseCreator/FileDynamicResponseCreator.cshtml b/netmockery/Views/Shared/Components/ResponseCreator/FileDynamicResponseCreator.cshtml index 35c1cdb..feff6e2 100644 --- a/netmockery/Views/Shared/Components/ResponseCreator/FileDynamicResponseCreator.cshtml +++ b/netmockery/Views/Shared/Components/ResponseCreator/FileDynamicResponseCreator.cshtml @@ -1,7 +1,7 @@ @using netmockery @model FileDynamicResponseCreator Script: - + @System.IO.Path.GetFileName(Model.Filename) diff --git a/netmockery/Views/Shared/Components/ResponseCreator/FileResponse.cshtml b/netmockery/Views/Shared/Components/ResponseCreator/FileResponse.cshtml index bd590f0..f32b258 100644 --- a/netmockery/Views/Shared/Components/ResponseCreator/FileResponse.cshtml +++ b/netmockery/Views/Shared/Components/ResponseCreator/FileResponse.cshtml @@ -1,7 +1,7 @@ @using netmockery @model FileResponse From file: - + @System.IO.Path.GetFileName(Model.Filename)