-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Created infrastructure for integration test using SpecsFor. Included 2 simple tests for redirecting anonymous users on Account/Manage and MimSeqs/Create page
- Loading branch information
Showing
11 changed files
with
204 additions
and
39 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
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MimryUnitTests | ||
{ | ||
public class MVCConstants | ||
{ | ||
public static readonly string Controller = "controller"; | ||
public static readonly string Action = "action"; | ||
} | ||
} |
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,50 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Mimry; | ||
using SpecsFor.Mvc; | ||
|
||
namespace MimryUnitTests.Controllers | ||
{ | ||
[TestClass] | ||
public class BaseIntegrationTest | ||
{ | ||
private static MvcWebApp s_App; | ||
private static SpecsForIntegrationHost s_IntegrationHost; | ||
|
||
protected static MvcWebApp App | ||
{ | ||
get { return s_App; } | ||
} | ||
|
||
[AssemblyInitialize] | ||
public static void Initialize(TestContext testContext) | ||
{ | ||
var config = new SpecsForMvcConfig(); | ||
|
||
config.UseIISExpress() | ||
.With(Project.Named("Mimry")) | ||
.ApplyWebConfigTransformForConfig("Release"); | ||
|
||
config.BuildRoutesUsing(r => RouteConfig.RegisterRoutes(r)); | ||
|
||
config.UseBrowser(BrowserDriver.Chrome); | ||
|
||
s_IntegrationHost = new SpecsForIntegrationHost(config); | ||
s_IntegrationHost.Start(); | ||
|
||
s_App = new MvcWebApp(); | ||
} | ||
|
||
[AssemblyCleanup()] | ||
public static void Cleanup() | ||
{ | ||
s_IntegrationHost.Shutdown(); | ||
} | ||
|
||
public static void TestRouteMatch(System.Web.Routing.RouteData route, string expectedController, string expectedAction) | ||
{ | ||
Assert.IsNotNull(route); | ||
Assert.AreEqual(expectedController, (string)route.Values[MVCConstants.Controller], true); | ||
Assert.AreEqual(expectedAction, (string)route.Values[MVCConstants.Action], true); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
MimryUnitTests/TestIntegration/Controllers/AccountIntegrationTest.cs
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,21 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SpecsFor; | ||
using SpecsFor.Mvc; | ||
using Mimry.Controllers; | ||
|
||
namespace MimryUnitTests.Controllers | ||
{ | ||
[TestClass] | ||
public class AccountIntegrationTest : BaseIntegrationTest | ||
{ | ||
[TestMethod] | ||
public void AccountManage_WithoutSession_RedirectsToLogin() | ||
{ | ||
AccountController.ManageMessageId? messageId = null; | ||
App.NavigateTo<AccountController>(c => c.Manage(messageId)); | ||
|
||
BaseIntegrationTest.TestRouteMatch(App.Route, "Account", "Login"); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
MimryUnitTests/TestIntegration/Controllers/MimSeqIntegrationTest.cs
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,20 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SpecsFor; | ||
using SpecsFor.Mvc; | ||
using Mimry.Controllers; | ||
|
||
namespace MimryUnitTests.Controllers | ||
{ | ||
[TestClass] | ||
public class MimSeqIntegrationTest : BaseIntegrationTest | ||
{ | ||
[TestMethod] | ||
public void MimSeqCreate_WithoutSession_RedirectsToLogin() | ||
{ | ||
string returnUrl = String.Empty; | ||
App.NavigateTo<MimSeqsController>(c => c.Create(returnUrl)); | ||
BaseIntegrationTest.TestRouteMatch(App.Route, "Account", "Login"); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.AspNet.Mvc" version="5.1.2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.Razor" version="3.1.2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebPages" version="3.1.2" targetFramework="net45" /> | ||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" /> | ||
<package id="Mvc4Futures" version="4.0.20710.0" targetFramework="net45" /> | ||
<package id="Selenium.Support" version="2.39.0" targetFramework="net45" /> | ||
<package id="Selenium.WebDriver" version="2.39.0" targetFramework="net45" /> | ||
<package id="SpecsFor.Mvc" version="3.1.0" targetFramework="net45" /> | ||
</packages> |