From 73f7897064a9d74a00219ceab0c52a1dfcac160a Mon Sep 17 00:00:00 2001 From: danbarua Date: Thu, 5 Jan 2012 15:45:10 +0000 Subject: [PATCH 1/3] PathUtils looks in /bin/ folder for static Content. Ability to bind HttpListener to multiple URIs --- src/ServiceStack.Common/Utils/PathUtils.cs | 9 +++- .../Support/HttpListenerBase.cs | 45 ++++++++++++------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/ServiceStack.Common/Utils/PathUtils.cs b/src/ServiceStack.Common/Utils/PathUtils.cs index 1826030b1a3..c731a09fe46 100644 --- a/src/ServiceStack.Common/Utils/PathUtils.cs +++ b/src/ServiceStack.Common/Utils/PathUtils.cs @@ -13,7 +13,9 @@ public static string MapAbsolutePath(string relativePath, string appendPartialPa var assemblyDirectoryPath = Path.GetDirectoryName(new Uri(typeof(PathUtils).Assembly.EscapedCodeBase).LocalPath); // Escape the assembly bin directory to the hostname directory - var hostDirectoryPath = assemblyDirectoryPath + appendPartialPathModifier; + var hostDirectoryPath = appendPartialPathModifier != null + ? assemblyDirectoryPath + appendPartialPathModifier + : assemblyDirectoryPath; return Path.GetFullPath(relativePath.Replace("~", hostDirectoryPath)); } @@ -23,12 +25,15 @@ public static string MapAbsolutePath(string relativePath, string appendPartialPa public static string MapAbsolutePath(this string relativePath) { - var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..{0}..", Path.DirectorySeparatorChar)); + /* When running self-hosted, static files with Build Action set to Content should be + * copied over into the /bin/ folder with the dlls */ + var mapPath = MapAbsolutePath(relativePath, null); return mapPath; } public static string MapHostAbsolutePath(this string relativePath) { + /* When running in Asp.Net, the root folder is one up from the /bin/ folder */ var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..", Path.DirectorySeparatorChar)); return mapPath; } diff --git a/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs b/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs index 524b9585f33..9f52fac60e1 100644 --- a/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs +++ b/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs @@ -105,23 +105,38 @@ public void Init() /// public virtual void Start(string urlBase) { - // *** Already running - just leave it in place - if (this.IsStarted) - return; - - if (this.Listener == null) - { - this.Listener = new HttpListener(); - } - - this.Listener.Prefixes.Add(urlBase); - - this.IsStarted = true; - this.Listener.Start(); - - ThreadPool.QueueUserWorkItem(Listen); + this.Start(new string[]{urlBase}); } + /// + /// Starts the Web Service + /// + /// A collection of Uris that acts as the base that the server is listening on. + /// Format should be: http://127.0.0.1:8080/ or http://127.0.0.1:8080/somevirtual/ + /// Note: the trailing backslash is required! For more info see the + /// HttpListener.Prefixes property on MSDN. + public virtual void Start(string[] urlBases) + { + // *** Already running - just leave it in place + if (this.IsStarted) + return; + + if (this.Listener == null) + { + this.Listener = new HttpListener(); + } + + foreach (var urlBase in urlBases) + { + this.Listener.Prefixes.Add(urlBase); + } + + this.IsStarted = true; + this.Listener.Start(); + + ThreadPool.QueueUserWorkItem(Listen); + } + // Loop here to begin processing of new requests. private void Listen(object state) { From 1325a3e2dd56b4eab0c89ad1fbdba1011c6a6250 Mon Sep 17 00:00:00 2001 From: danbarua Date: Fri, 6 Jan 2012 09:59:17 +0000 Subject: [PATCH 2/3] Revert "PathUtils looks in /bin/ folder for static Content. Ability to bind HttpListener to multiple URIs" This reverts commit 73f7897064a9d74a00219ceab0c52a1dfcac160a. --- src/ServiceStack.Common/Utils/PathUtils.cs | 9 +--- .../Support/HttpListenerBase.cs | 45 +++++++------------ 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/src/ServiceStack.Common/Utils/PathUtils.cs b/src/ServiceStack.Common/Utils/PathUtils.cs index c731a09fe46..1826030b1a3 100644 --- a/src/ServiceStack.Common/Utils/PathUtils.cs +++ b/src/ServiceStack.Common/Utils/PathUtils.cs @@ -13,9 +13,7 @@ public static string MapAbsolutePath(string relativePath, string appendPartialPa var assemblyDirectoryPath = Path.GetDirectoryName(new Uri(typeof(PathUtils).Assembly.EscapedCodeBase).LocalPath); // Escape the assembly bin directory to the hostname directory - var hostDirectoryPath = appendPartialPathModifier != null - ? assemblyDirectoryPath + appendPartialPathModifier - : assemblyDirectoryPath; + var hostDirectoryPath = assemblyDirectoryPath + appendPartialPathModifier; return Path.GetFullPath(relativePath.Replace("~", hostDirectoryPath)); } @@ -25,15 +23,12 @@ public static string MapAbsolutePath(string relativePath, string appendPartialPa public static string MapAbsolutePath(this string relativePath) { - /* When running self-hosted, static files with Build Action set to Content should be - * copied over into the /bin/ folder with the dlls */ - var mapPath = MapAbsolutePath(relativePath, null); + var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..{0}..", Path.DirectorySeparatorChar)); return mapPath; } public static string MapHostAbsolutePath(this string relativePath) { - /* When running in Asp.Net, the root folder is one up from the /bin/ folder */ var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..", Path.DirectorySeparatorChar)); return mapPath; } diff --git a/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs b/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs index 9f52fac60e1..524b9585f33 100644 --- a/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs +++ b/src/ServiceStack/WebHost.EndPoints/Support/HttpListenerBase.cs @@ -105,37 +105,22 @@ public void Init() /// public virtual void Start(string urlBase) { - this.Start(new string[]{urlBase}); - } + // *** Already running - just leave it in place + if (this.IsStarted) + return; + + if (this.Listener == null) + { + this.Listener = new HttpListener(); + } + + this.Listener.Prefixes.Add(urlBase); - /// - /// Starts the Web Service - /// - /// A collection of Uris that acts as the base that the server is listening on. - /// Format should be: http://127.0.0.1:8080/ or http://127.0.0.1:8080/somevirtual/ - /// Note: the trailing backslash is required! For more info see the - /// HttpListener.Prefixes property on MSDN. - public virtual void Start(string[] urlBases) - { - // *** Already running - just leave it in place - if (this.IsStarted) - return; - - if (this.Listener == null) - { - this.Listener = new HttpListener(); - } - - foreach (var urlBase in urlBases) - { - this.Listener.Prefixes.Add(urlBase); - } - - this.IsStarted = true; - this.Listener.Start(); - - ThreadPool.QueueUserWorkItem(Listen); - } + this.IsStarted = true; + this.Listener.Start(); + + ThreadPool.QueueUserWorkItem(Listen); + } // Loop here to begin processing of new requests. private void Listen(object state) From 2587bffc576ad4bec19d66822d96345242bc5726 Mon Sep 17 00:00:00 2001 From: danbarua Date: Fri, 6 Jan 2012 11:05:07 +0000 Subject: [PATCH 3/3] Fixed MapAbsolutePath to work in Self-Hosted scenario. Use MapProjectPath to find files in a VS (Unit Test) scenario. --- src/ServiceStack.Common/Utils/PathUtils.cs | 31 +++++++++++++++++-- .../OAuth/OAuthUserSessionTests.cs | 2 +- .../OAuthUserSessionWithoutTestSourceTests.cs | 2 +- .../Formats/MarkdownFormatTests.cs | 14 ++++----- .../Formats/MockClass.cs | 2 +- .../Formats/TemplateTests.cs | 6 ++-- .../Formats/TextBlockTests.cs | 2 +- .../Formats/UseCaseTests.cs | 2 +- .../Formats/ViewTests.cs | 8 ++--- .../Formats_Razor/TemplateTests.cs | 6 ++-- .../FileUploadTests.cs | 8 ++--- ...erviceStack.WebHost.Endpoints.Tests.csproj | 8 +++-- .../Support/Services/FileUploadService.cs | 2 +- 13 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/ServiceStack.Common/Utils/PathUtils.cs b/src/ServiceStack.Common/Utils/PathUtils.cs index 1826030b1a3..dc3cfd8ffb2 100644 --- a/src/ServiceStack.Common/Utils/PathUtils.cs +++ b/src/ServiceStack.Common/Utils/PathUtils.cs @@ -13,7 +13,9 @@ public static string MapAbsolutePath(string relativePath, string appendPartialPa var assemblyDirectoryPath = Path.GetDirectoryName(new Uri(typeof(PathUtils).Assembly.EscapedCodeBase).LocalPath); // Escape the assembly bin directory to the hostname directory - var hostDirectoryPath = assemblyDirectoryPath + appendPartialPathModifier; + var hostDirectoryPath = appendPartialPathModifier != null + ? assemblyDirectoryPath + appendPartialPathModifier + : assemblyDirectoryPath; return Path.GetFullPath(relativePath.Replace("~", hostDirectoryPath)); } @@ -21,12 +23,37 @@ public static string MapAbsolutePath(string relativePath, string appendPartialPa return relativePath; } - public static string MapAbsolutePath(this string relativePath) + /// + /// Maps the path of a file in the context of a VS project + /// + /// the relative path + /// the absolute path + /// Assumes static content is two directories above the /bin/ directory, + /// eg. in a unit test scenario the assembly would be in /bin/Debug/. + public static string MapProjectPath(this string relativePath) { var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..{0}..", Path.DirectorySeparatorChar)); return mapPath; } + /// + /// Maps the path of a file in a self-hosted scenario + /// + /// the relative path + /// the absolute path + /// Assumes static content is copied to /bin/ folder with the assemblies + public static string MapAbsolutePath(this string relativePath) + { + var mapPath = MapAbsolutePath(relativePath, null); + return mapPath; + } + + /// + /// Maps the path of a file in an Asp.Net hosted scenario + /// + /// the relative path + /// the absolute path + /// Assumes static content is in the parent folder of the /bin/ directory public static string MapHostAbsolutePath(this string relativePath) { var mapPath = MapAbsolutePath(relativePath, string.Format("{0}..", Path.DirectorySeparatorChar)); diff --git a/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs b/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs index 675bf96279f..8d2667edf7d 100644 --- a/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs +++ b/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs @@ -60,7 +60,7 @@ public static IEnumerable UserAuthRepositorys sqliteRepo.Clear(); yield return new TestCaseData(sqliteRepo); - var dbFilePath = "~/App_Data/auth.sqlite".MapAbsolutePath(); + var dbFilePath = "~/App_Data/auth.sqlite".MapProjectPath(); if (File.Exists(dbFilePath)) File.Delete(dbFilePath); var sqliteDbFactory = new OrmLiteConnectionFactory(dbFilePath); var sqliteDbRepo = new OrmLiteAuthRepository(sqliteDbFactory); diff --git a/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionWithoutTestSourceTests.cs b/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionWithoutTestSourceTests.cs index e8177dc86e0..e7a989b1070 100644 --- a/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionWithoutTestSourceTests.cs +++ b/tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionWithoutTestSourceTests.cs @@ -51,7 +51,7 @@ public void SetUp() userAuthRepositorys.Add(sqliteInMemoryRepo); var sqliteDbFactory = new OrmLiteConnectionFactory( - "~/App_Data/auth.sqlite".MapAbsolutePath()); + "~/App_Data/auth.sqlite".MapProjectPath()); var sqliteDbRepo = new OrmLiteAuthRepository(sqliteDbFactory); sqliteDbRepo.CreateMissingTables(); userAuthRepositorys.Add(sqliteDbRepo); diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats/MarkdownFormatTests.cs b/tests/ServiceStack.ServiceHost.Tests/Formats/MarkdownFormatTests.cs index d635d5eaf8a..fe1d94c8ab0 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats/MarkdownFormatTests.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats/MarkdownFormatTests.cs @@ -45,7 +45,7 @@ public void TestFixtureSetUp() //staticTemplatePath = "~/AppData/Template/default.shtml".MapAbsolutePath(); //staticTemplateContent = File.ReadAllText(staticTemplatePath); - dynamicPagePath = "~/Views/Template/DynamicTpl.md".MapAbsolutePath(); + dynamicPagePath = "~/Views/Template/DynamicTpl.md".MapProjectPath(); dynamicPageContent = File.ReadAllText(dynamicPagePath); //dynamicListPagePath = "~/Views/Template/DynamicListTpl.md".MapAbsolutePath(); @@ -61,7 +61,7 @@ public void OnBeforeEachTest() [Test] public void Can_load_all_markdown_files() { - markdownFormat.RegisterMarkdownPages("~/".MapAbsolutePath()); + markdownFormat.RegisterMarkdownPages("~/".MapProjectPath()); Assert.That(markdownFormat.ViewPages.Count, Is.EqualTo(viewPageNames.Length)); Assert.That(markdownFormat.ViewSharedPages.Count, Is.EqualTo(sharedViewPageNames.Length)); @@ -78,8 +78,8 @@ public void Can_load_all_markdown_files() [Test] public void Can_Render_StaticPage() { - markdownFormat.RegisterMarkdownPages("~/".MapAbsolutePath()); - var html = markdownFormat.RenderStaticPageHtml("~/AppData/NoTemplate/Static".MapAbsolutePath()); + markdownFormat.RegisterMarkdownPages("~/".MapProjectPath()); + var html = markdownFormat.RenderStaticPageHtml("~/AppData/NoTemplate/Static".MapProjectPath()); Assert.That(html, Is.Not.Null); Assert.That(html, Is.StringStarting("

Static Markdown template

")); @@ -88,8 +88,8 @@ public void Can_Render_StaticPage() [Test] public void Can_Render_StaticPage_WithTemplate() { - markdownFormat.RegisterMarkdownPages("~/".MapAbsolutePath()); - var html = markdownFormat.RenderStaticPageHtml("~/AppData/Template/StaticTpl".MapAbsolutePath()); + markdownFormat.RegisterMarkdownPages("~/".MapProjectPath()); + var html = markdownFormat.RenderStaticPageHtml("~/AppData/Template/StaticTpl".MapProjectPath()); Console.WriteLine(html); @@ -101,7 +101,7 @@ public void Can_Render_StaticPage_WithTemplate() public void Can_Render_DynamicPage() { var person = new Person { FirstName = "Demis", LastName = "Bellot" }; - markdownFormat.RegisterMarkdownPages("~/".MapAbsolutePath()); + markdownFormat.RegisterMarkdownPages("~/".MapProjectPath()); var html = markdownFormat.RenderDynamicPageHtml("Dynamic", person); diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats/MockClass.cs b/tests/ServiceStack.ServiceHost.Tests/Formats/MockClass.cs index 6218506d718..022eee1e0eb 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats/MockClass.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats/MockClass.cs @@ -27,7 +27,7 @@ public ServiceStack.Markdown.MvcHtmlString EvalExpr_0() //[Test] public void Compare_access() { - var filePath = "~/AppData/TestsResults/Customer.htm".MapAbsolutePath(); + var filePath = "~/AppData/TestsResults/Customer.htm".MapProjectPath(); const int Times = 10000; var start = DateTime.Now; diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats/TemplateTests.cs b/tests/ServiceStack.ServiceHost.Tests/Formats/TemplateTests.cs index 957ed58ff9e..ff0d5444e2d 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats/TemplateTests.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats/TemplateTests.cs @@ -27,13 +27,13 @@ public class TemplateTests [TestFixtureSetUp] public void TestFixtureSetUp() { - staticTemplatePath = "~/Views/Template/default.shtml".MapAbsolutePath(); + staticTemplatePath = "~/Views/Template/default.shtml".MapProjectPath(); staticTemplateContent = File.ReadAllText(staticTemplatePath); - dynamicPagePath = "~/Views/Template/DynamicTpl.md".MapAbsolutePath(); + dynamicPagePath = "~/Views/Template/DynamicTpl.md".MapProjectPath(); dynamicPageContent = File.ReadAllText(dynamicPagePath); - dynamicListPagePath = "~/Views/Template/DynamicListTpl.md".MapAbsolutePath(); + dynamicListPagePath = "~/Views/Template/DynamicListTpl.md".MapProjectPath(); dynamicListPageContent = File.ReadAllText(dynamicListPagePath); } diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats/TextBlockTests.cs b/tests/ServiceStack.ServiceHost.Tests/Formats/TextBlockTests.cs index 02709502fb9..bb9d2fffecd 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats/TextBlockTests.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats/TextBlockTests.cs @@ -17,7 +17,7 @@ public class TextBlockTests [TestFixtureSetUp] public void TestFixtureSetUp() { - dynamicListPagePath = "~/Views/Template/DynamicListTpl.md".MapAbsolutePath(); + dynamicListPagePath = "~/Views/Template/DynamicListTpl.md".MapProjectPath(); dynamicListPageContent = File.ReadAllText(dynamicListPagePath); } diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats/UseCaseTests.cs b/tests/ServiceStack.ServiceHost.Tests/Formats/UseCaseTests.cs index ec54e74bca7..5e7d547bdc6 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats/UseCaseTests.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats/UseCaseTests.cs @@ -73,7 +73,7 @@ public class UseCaseTests : MarkdownTestBase [TestFixtureSetUp] public void TestFixtureSetUp() { - var jsonPages = File.ReadAllText("~/AppData/Pages.json".MapAbsolutePath()); + var jsonPages = File.ReadAllText("~/AppData/Pages.json".MapProjectPath()); Pages = JsonSerializer.DeserializeFromString>(jsonPages); diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats/ViewTests.cs b/tests/ServiceStack.ServiceHost.Tests/Formats/ViewTests.cs index 25c7dc021bf..15945586e7a 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats/ViewTests.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats/ViewTests.cs @@ -25,7 +25,7 @@ public class ViewTests [TestFixtureSetUp] public void TestFixtureSetUp() { - var json = "~/AppData/ALFKI.json".MapAbsolutePath().ReadAllText(); + var json = "~/AppData/ALFKI.json".MapProjectPath().ReadAllText(); response = JsonSerializer.DeserializeFromString(json); } @@ -42,7 +42,7 @@ public class AppHost : IAppHost public AppHost() { this.Config = new EndpointHostConfig { - MarkdownSearchPath = "~".MapAbsolutePath(), + MarkdownSearchPath = "~".MapProjectPath(), MarkdownReplaceTokens = new Dictionary(), IgnoreFormatsInMetadata = new HashSet(), }; @@ -235,14 +235,14 @@ public void Does_process_Markdown_pages() var markdownHandler = new MarkdownHandler { MarkdownFormat = markdownFormat, PathInfo = "/AppData/NoTemplate/Static.md", - FilePath = "~/AppData/NoTemplate/Static.md".MapAbsolutePath(), + FilePath = "~/AppData/NoTemplate/Static.md".MapProjectPath(), }; var httpReq = new MockHttpRequest { QueryString = new NameValueCollection() }; var httpRes = new MockHttpResponse(); markdownHandler.ProcessRequest(httpReq, httpRes, "Static"); var expectedHtml = markdownFormat.Transform( - File.ReadAllText("~/AppData/NoTemplate/Static.md".MapAbsolutePath())); + File.ReadAllText("~/AppData/NoTemplate/Static.md".MapProjectPath())); httpRes.Close(); Assert.That(httpRes.Contents, Is.EqualTo(expectedHtml)); diff --git a/tests/ServiceStack.ServiceHost.Tests/Formats_Razor/TemplateTests.cs b/tests/ServiceStack.ServiceHost.Tests/Formats_Razor/TemplateTests.cs index 3f61b03cdb9..e2b114a6110 100644 --- a/tests/ServiceStack.ServiceHost.Tests/Formats_Razor/TemplateTests.cs +++ b/tests/ServiceStack.ServiceHost.Tests/Formats_Razor/TemplateTests.cs @@ -121,13 +121,13 @@ public class RazorTemplateTests [TestFixtureSetUp] public void TestFixtureSetUp() { - staticTemplatePath = "~/Views/Template/_Layout.cshtml".MapAbsolutePath(); + staticTemplatePath = "~/Views/Template/_Layout.cshtml".MapProjectPath(); staticTemplateContent = File.ReadAllText(staticTemplatePath); - dynamicPagePath = "~/Views/Template/DynamicTpl.cshtml".MapAbsolutePath(); + dynamicPagePath = "~/Views/Template/DynamicTpl.cshtml".MapProjectPath(); dynamicPageContent = File.ReadAllText(dynamicPagePath); - dynamicListPagePath = "~/Views/Template/DynamicListTpl.cshtml".MapAbsolutePath(); + dynamicListPagePath = "~/Views/Template/DynamicListTpl.cshtml".MapProjectPath(); dynamicListPageContent = File.ReadAllText(dynamicListPagePath); templateArgs = person; diff --git a/tests/ServiceStack.WebHost.Endpoints.Tests/FileUploadTests.cs b/tests/ServiceStack.WebHost.Endpoints.Tests/FileUploadTests.cs index 2b5f6131139..4fbcf9edfee 100644 --- a/tests/ServiceStack.WebHost.Endpoints.Tests/FileUploadTests.cs +++ b/tests/ServiceStack.WebHost.Endpoints.Tests/FileUploadTests.cs @@ -93,7 +93,7 @@ public void AssertResponse(HttpWebResponse response, string contentType) [Test] public void Can_POST_upload_file() { - var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapAbsolutePath()); + var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapProjectPath()); var webRequest = (HttpWebRequest)WebRequest.Create(ListeningOn + "/fileuploads"); webRequest.Accept = ContentType.Json; @@ -114,7 +114,7 @@ public void Can_POST_upload_file_using_ServiceClient() { IServiceClient client = new JsonServiceClient(ListeningOn); - var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapAbsolutePath()); + var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapProjectPath()); var response = client.PostFile( @@ -133,7 +133,7 @@ public void Can_handle_error_on_POST_upload_file_using_ServiceClient() { IServiceClient client = new JsonServiceClient(ListeningOn); - var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapAbsolutePath()); + var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapProjectPath()); try { @@ -155,7 +155,7 @@ public void Can_handle_error_on_POST_upload_file_using_ServiceClient() [Test] public void Can_GET_upload_file() { - var uploadedFile = new FileInfo("~/TestExistingDir/upload.html".MapAbsolutePath()); + var uploadedFile = new FileInfo("~/TestExistingDir/upload.html".MapProjectPath()); var webRequest = (HttpWebRequest)WebRequest.Create(ListeningOn + "/fileuploads/TestExistingDir/upload.html"); var expectedContents = new StreamReader(uploadedFile.OpenRead()).ReadToEnd(); diff --git a/tests/ServiceStack.WebHost.Endpoints.Tests/ServiceStack.WebHost.Endpoints.Tests.csproj b/tests/ServiceStack.WebHost.Endpoints.Tests/ServiceStack.WebHost.Endpoints.Tests.csproj index 4187c7fa81c..c5f7567f1a7 100644 --- a/tests/ServiceStack.WebHost.Endpoints.Tests/ServiceStack.WebHost.Endpoints.Tests.csproj +++ b/tests/ServiceStack.WebHost.Endpoints.Tests/ServiceStack.WebHost.Endpoints.Tests.csproj @@ -229,8 +229,12 @@ sqlite3.dll PreserveNewest - - + + PreserveNewest + + + PreserveNewest + diff --git a/tests/ServiceStack.WebHost.Endpoints.Tests/Support/Services/FileUploadService.cs b/tests/ServiceStack.WebHost.Endpoints.Tests/Support/Services/FileUploadService.cs index 88700e7ae68..26d52abd0b2 100644 --- a/tests/ServiceStack.WebHost.Endpoints.Tests/Support/Services/FileUploadService.cs +++ b/tests/ServiceStack.WebHost.Endpoints.Tests/Support/Services/FileUploadService.cs @@ -46,7 +46,7 @@ public override object OnGet(FileUpload request) if (request.RelativePath.IsNullOrEmpty()) throw new ArgumentNullException("RelativePath"); - var filePath = ("~/" + request.RelativePath).MapAbsolutePath(); + var filePath = ("~/" + request.RelativePath).MapProjectPath(); if (!File.Exists(filePath)) throw new FileNotFoundException(request.RelativePath);