Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6 Get base url from request rather than hard coding it
- Loading branch information
Showing
7 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using BookWorm.Services.Email; | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace BookWorm.Tests.Services | ||
{ | ||
[TestClass] | ||
public class UrlFormattingHelperTests | ||
{ | ||
[TestMethod] | ||
public void ShouldCombineSchemeAndAuthority() | ||
{ | ||
var helper = new UrlFormattingHelper(); | ||
var baseUrl = helper.GetBaseUrl(new Uri("http://localhost:1234/soup")); | ||
baseUrl.Should().Be("http://localhost:1234"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace BookWorm.Services.Email | ||
{ | ||
public class CurrentHttpContextWrapper | ||
{ | ||
public virtual string GetBaseUrl() | ||
{ | ||
var urlFormattingHelper = new UrlFormattingHelper(); | ||
return urlFormattingHelper.GetBaseUrl(System.Web.HttpContext.Current.Request.Url); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace BookWorm.Services.Email | ||
{ | ||
public class UrlFormattingHelper | ||
{ | ||
public virtual string GetBaseUrl(Uri url) | ||
{ | ||
return string.Format("{0}://{1}", url.Scheme, url.Authority ); | ||
} | ||
} | ||
} |