-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8db97a8
commit 0f06340
Showing
3 changed files
with
413 additions
and
344 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading; | ||
using NUnit.Framework; | ||
using Unosquare.Labs.EmbedIO.Modules; | ||
using Unosquare.Labs.EmbedIO.Tests.Properties; | ||
using Unosquare.Labs.EmbedIO.Tests.TestObjects; | ||
|
||
namespace Unosquare.Labs.EmbedIO.Tests | ||
{ | ||
[TestFixture] | ||
public class RegExRoutingTest | ||
{ | ||
protected WebServer WebServer; | ||
protected TestConsoleLog Logger = new TestConsoleLog(); | ||
|
||
[SetUp] | ||
public void Init() | ||
{ | ||
WebServer = | ||
new WebServer(Resources.ServerAddress, Logger, RoutingStrategy.RegEx) | ||
.WithWebApiController<TestRegexController>(); | ||
WebServer.RunAsync(); | ||
} | ||
|
||
[Test] | ||
public void TestWebApi() | ||
{ | ||
Assert.IsNotNull(WebServer.Module<WebApiModule>(), "WebServer has WebApiModule"); | ||
|
||
Assert.AreEqual(WebServer.Module<WebApiModule>().ControllersCount, 1, "WebApiModule has one controller"); | ||
} | ||
|
||
[Test] | ||
public void GetJsonDataWithRegexId() | ||
{ | ||
TestHelper.ValidatePerson(Resources.ServerAddress + TestRegexController.RelativePath + "regex/1"); | ||
} | ||
|
||
[Test] | ||
public void GetJsonDatAsyncaWithRegexId() | ||
{ | ||
TestHelper.ValidatePerson(Resources.ServerAddress + TestRegexController.RelativePath + "regexasync/1"); | ||
} | ||
|
||
[Test] | ||
public void GetJsonDataWithRegexDate() | ||
{ | ||
var person = PeopleRepository.Database.First(); | ||
TestHelper.ValidatePerson(Resources.ServerAddress + TestRegexController.RelativePath + "regexdate/" + | ||
person.DoB.ToString("yyyy-MM-dd")); | ||
} | ||
|
||
[Test] | ||
public void GetJsonDataWithRegexWithTwoParams() | ||
{ | ||
var person = PeopleRepository.Database.First(); | ||
TestHelper.ValidatePerson(Resources.ServerAddress + TestRegexController.RelativePath + "regextwo/" + | ||
person.MainSkill + "/" + person.Age); | ||
} | ||
|
||
[TearDown] | ||
public void Kill() | ||
{ | ||
Thread.Sleep(TimeSpan.FromSeconds(1)); | ||
WebServer.Dispose(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.