Permalink
Browse files

do some renaming to increase readability

  • Loading branch information...
gregoryjscott committed Oct 14, 2010
1 parent f0a1d9e commit 3b35a415e43c3a1d3a9ccd474611fd7b838e794a
Showing with 8 additions and 33 deletions.
  1. +5 −30 MvcIntegrationTestFramework/Hosting/AppHost.cs
  2. +3 −3 MyMvcApplication.Tests/HomeControllerTests.cs
@@ -35,7 +35,7 @@ private AppHost(string appPhysicalDirectory, string virtualDirectory = "/")
});
}
- public void BrowsingSession(Action<BrowsingSession> testScript)
+ public void Start(Action<BrowsingSession> testScript)
{
var serializableDelegate = new SerializableDelegate<Action<BrowsingSession>>(testScript);
_appDomainProxy.RunBrowsingSessionInAppDomain(serializableDelegate);
@@ -107,39 +107,14 @@ private static void RefreshEventsList(HttpApplication appInstance)
/// <summary>
/// Creates an instance of the AppHost so it can be used to simulate a browsing session.
/// </summary>
- /// <param name="pathToYourWebProject">
- /// The path to your web project. This is optional if you don't
- /// specify we try to guess that it is in the first directory like
- /// ../../../*/web.config
- /// </param>
/// <returns></returns>
- public static AppHost Simulate(string pathToYourWebProject = null)
+ public static AppHost Simulate(string mvcProjectName)
{
- if (pathToYourWebProject == null)
- {
- var guessDirectory = new DirectoryInfo(
+ var pathToMvcProject = new DirectoryInfo(
Path.GetFullPath(
- Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..")));
+ Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", mvcProjectName)));
- var projectDirs = guessDirectory.GetDirectories();
- foreach (var pd in projectDirs)
- {
- if (pd.GetFiles("web.config").Length == 1)
- {
- pathToYourWebProject = pd.FullName;
- continue;
- }
- }
- }
-
- var ourDll = Path.Combine(pathToYourWebProject, "bin", "MvcIntegrationTestFramework.dll");
- if (!File.Exists(ourDll))
- {
- File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MvcIntegrationTestFramework.dll"), ourDll);
- }
-
- //return new AppHost(pathToYourWebProject, "/__test");
- return new AppHost(pathToYourWebProject);
+ return new AppHost(pathToMvcProject.ToString());
}
}
}
@@ -11,7 +11,7 @@ public class HomeControllerTests
[Test]
public void Root_Url_Renders_Index_View()
{
- AppHost.Simulate().BrowsingSession(browsingSession => {
+ AppHost.Simulate("MyMvcApplication").Start(browsingSession => {
// Request the root URL
RequestResult result = browsingSession.Get("");
@@ -28,7 +28,7 @@ public void Root_Url_Renders_Index_View()
[Test]
public void WorkWithCookiesAndSession()
{
- AppHost.Simulate().BrowsingSession(browsingSession =>
+ AppHost.Simulate("MyMvcApplication").Start(browsingSession =>
{
string url = "home/DoStuffWithSessionAndCookies";
browsingSession.Get(url);
@@ -53,7 +53,7 @@ public void LogInProcess()
{
string securedActionUrl = "/home/SecretAction";
- AppHost.Simulate().BrowsingSession(browsingSession =>
+ AppHost.Simulate("MyMvcApplication").Start(browsingSession =>
{
// First try to request a secured page without being logged in
RequestResult initialRequestResult = browsingSession.Get(securedActionUrl);

0 comments on commit 3b35a41

Please sign in to comment.