Permalink
Browse files

converted all the StoryTeller tests to only use WebDriver and/or the …

…new Serenity bits
  • Loading branch information...
1 parent 7acc7f4 commit 212ea84bc6eda9618b2ae2e5cf9d13b07f16718a @jeremydmiller jeremydmiller committed Dec 1, 2011
View
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<aliases xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Aliases>
- <alias name="fubu-testing" folder="D:\home\oss\fubumvc\src\FubuTestApplication" />
+ <alias name="fubu-testing" folder="C:\code\fubumvc\src\FubuTestApplication" />
<alias name="pak1" folder="src/TestPackage1" />
<alias name="pak3" folder="src/TestPackage3" />
<alias name="pak2" folder="src/TestPackage2" />
View
@@ -11,13 +11,13 @@ public class Template
[TestFixtureSetUp]
public void SetupRunner()
{
- runner = new ProjectTestRunner(@"C:\git\fubumvc\Storyteller.xml");
+ runner = new ProjectTestRunner(@"C:\code\fubumvc\Storyteller.xml");
}
[Test]
- public void Request_json()
+ public void Simple_explicit_combination()
{
- runner.RunAndAssertTest("Conneg/Request json");
+ runner.RunAndAssertTest("Assets/Combinations/Simple explicit combination");
}
[TestFixtureTearDown]
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -19,7 +19,15 @@ public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
HostingEnvironment.RegisterVirtualPathProvider(provider);
- packages.Each(x => x.ForFolder(BottleFiles.WebContentFolder, provider.RegisterContentDirectory));
+ packages.Each(x =>
+ {
+ x.ForFolder(BottleFiles.WebContentFolder, directory =>
+ {
+ log.Trace("Adding the bottle directory {0} to the virtual directory provider", directory);
+ provider.RegisterContentDirectory(directory);
+ }
+ );
+ });
}
public override string ToString()
@@ -113,7 +113,7 @@ public IEnumerable<IActivator> GetAllActivators()
if (_initializeSingletonsToWorkAroundSMBug)
{
- new SingletonSpinupActivator(_container).Activate(null, null);
+ yield return new SingletonSpinupActivator(_container);
}
}
View
@@ -65,6 +65,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FubuMVC.Diagnostics.Tests",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerenityRunner", "SerenityRunner\SerenityRunner.csproj", "{FC5172BC-C96A-4656-B87B-36978B19AD85}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTesting", "StoryTellerTesting\IntegrationTesting.csproj", "{022C7B24-4417-493F-9F70-E3F4035FBEDA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -513,6 +515,21 @@ Global
{FC5172BC-C96A-4656-B87B-36978B19AD85}.Retail|Mixed Platforms.Build.0 = Release|x86
{FC5172BC-C96A-4656-B87B-36978B19AD85}.Retail|x86.ActiveCfg = Release|x86
{FC5172BC-C96A-4656-B87B-36978B19AD85}.Retail|x86.Build.0 = Release|x86
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Release|x86.ActiveCfg = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Retail|Any CPU.ActiveCfg = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Retail|Any CPU.Build.0 = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Retail|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Retail|Mixed Platforms.Build.0 = Release|Any CPU
+ {022C7B24-4417-493F-9F70-E3F4035FBEDA}.Retail|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -56,6 +56,7 @@
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
+ <Content Include="content\images\icon-add-alt.png" />
<Content Include="content\images\grid\cd_run.gif" />
<Content Include="content\images\grid\dirty.gif" />
<Content Include="content\images\grid\down.gif" />
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using FubuMVC.Core.Assets.Http;
@@ -22,6 +23,13 @@ public ApplicationDriver(IApplicationUnderTest application)
public void NavigateTo(object target)
{
var url = _application.Urls.UrlFor(target);
+
+ NavigateToUrl(url);
+ }
+
+ public void NavigateToUrl(string url)
+ {
+ Debug.WriteLine("Navigating to " + url);
_application.Driver.Navigate().GoToUrl(url);
}
@@ -50,6 +58,14 @@ public void NavigateToHome()
{
_application.Driver.Navigate().GoToUrl(_application.RootUrl);
}
+
+ public IWebDriver Driver
+ {
+ get
+ {
+ return _application.Driver;
+ }
+ }
}
public class AssetTagsState
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Net;
+using System.Text;
+using System.Web;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using FubuCore;
@@ -36,10 +38,13 @@ public HttpResponse PostJson<T>(T target, string contentType = "text/json", stri
{
return post(target, contentType, accept, stream =>
{
- var json = new JavaScriptSerializer().Serialize(target);
- var writer = new StreamWriter(stream);
+ var serializer = new JavaScriptSerializer();
+
- writer.Write(json);
+ var json = serializer.Serialize(target);
+ var bytes = Encoding.Default.GetBytes(json);
+
+ stream.Write(bytes, 0, bytes.Length);
});
}
@@ -62,6 +67,16 @@ public HttpResponse GetHtml(object subject)
return request.ToHttpCall();
}
+ public HttpResponse GetHtml(string url)
+ {
+ var request = WebRequest.Create(url);
+ request.Method = "GET";
+ request.ContentType = MimeType.HttpFormMimetype;
+
+
+ return request.ToHttpCall();
+ }
+
public string ReadTextFrom(object input)
{
var url = _urls.UrlFor(input);
@@ -76,9 +91,12 @@ private HttpResponse post(object urlTarget, string contentType, string accept, A
request.ContentType = contentType;
request.Method = "POST";
- request.Headers[HttpRequestHeader.Accept] = accept;
- setRequest(request.GetRequestStream());
+ request.As<HttpWebRequest>().Accept = accept;
+
+ var stream = request.GetRequestStream();
+ setRequest(stream);
+ stream.Close();
return request.ToHttpCall();
}
@@ -1,8 +1,11 @@
+using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
+using System.Web.Script.Serialization;
using System.Xml;
+using HtmlTags;
namespace Serenity.Endpoints
{
@@ -69,5 +72,15 @@ public override string ToString()
return _body;
}
+
+ public string Source()
+ {
+ return _body;
+ }
+
+ public T ReadAsJson<T>()
+ {
+ return new JavaScriptSerializer().Deserialize<T>(_body);
+ }
}
}
@@ -1,83 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Net;
-using System.Web.Script.Serialization;
-using FubuCore;
-using StoryTeller.Assertions;
-using WatiN.Core;
-
-namespace IntegrationTesting
-{
- [MarkedForTermination("Will be eliminated in favor of WebDriver world")]
- public class ApplicationDriver
- {
- private WatiN.Core.IE _browser;
-
- public void NavigateTo(string url)
- {
- Debug.WriteLine("Navigating browser to " + url);
-
- if (_browser == null)
- {
- _browser = new IE();
- }
-
- _browser.GoTo(url);
- }
-
-
- public void Teardown()
- {
- if (_browser != null)
- {
- try
- {
- _browser.Close();
- _browser.Dispose();
- }
- catch (Exception)
- {
- }
- }
-
- try
- {
- var ieProcessList = Process.GetProcessesByName("iexplore");
- foreach (var process in ieProcessList)
- {
- process.Kill();
- }
- }
- catch (Exception e)
- {
- Debug.WriteLine(e.ToString());
- }
-
- _browser = null;
- }
-
- public T InvokeJson<T>(string url, object message)
- {
- var client = new WebClient();
- var serializer = new JavaScriptSerializer();
- var json = serializer.Serialize(message);
-
- client.Headers[HttpRequestHeader.ContentType] = "text/json";
- client.Headers[HttpRequestHeader.Accept] = "text/json";
-
- var response = client.UploadString(url, json);
-
- return serializer.Deserialize<T>(response);
- }
-
- public string InvokeString(string url)
- {
- return new WebClient().DownloadString(url);
- }
-
- public IE Browser
- {
- get { return _browser; }
- }
- }
-}
@@ -86,6 +86,8 @@ public void RunFubu(string commandLine)
var processOutput = process.StandardOutput.ReadToEnd();
process.WaitForExit();
+ Debug.WriteLine(processOutput);
+
if (process.ExitCode != 0)
{
StoryTellerAssert.Fail("Command failed! -- " + commandLine + "\n" + processOutput);
@@ -1,5 +1,7 @@
using System;
using FubuMVC.Core.Diagnostics.Querying;
+using OpenQA.Selenium;
+using Serenity;
using StoryTeller;
using StoryTeller.Engine;
using TestPackage1;
@@ -34,29 +36,30 @@ public bool InvokingJsonService()
Name = name
};
- var response =
- _application.InvokeJson<JsonSerializedMessage>("http://localhost/fubu-testing/testpackage1/json/sendmessage", message);
-
+ var httpResponse = _application.GetEndpointDriver().PostJson(message);
+
+ var response= httpResponse.ReadAsJson<JsonSerializedMessage>();
return response.Name == name;
}
[FormatAs("Can successfully invoke a string endpoint from this package")]
public bool InvokeStringEndpoint()
{
- return _application.InvokeString("http://localhost/fubu-testing/testpackage1/string/sayhello") == "Hello";
+ var url = "http://localhost/fubu-testing/testpackage1/string/sayhello";
+ return _application.GetEndpointDriver().GetHtml(url).Source() == "Hello";
}
[FormatAs("Open the browser to {url}")]
public void OpenPage(string url)
{
- _application.NavigateTo(url);
+ _application.NavigateToUrl(url);
}
[FormatAs("The text of the 'name' span in the page should be {name}")]
public string TextOfNameElementShouldBe()
{
- return _application.Browser.Element("name").Text;
+ return _application.Driver.FindElement(By.Id("name")).Text;
}
}
}
@@ -1,4 +1,6 @@
using FubuMVC.Core.Diagnostics.Querying;
+using OpenQA.Selenium;
+using Serenity;
using StoryTeller;
using StoryTeller.Engine;
@@ -28,7 +30,7 @@ public void OpenPage(string url)
[FormatAs("The text of the 'message' h1 in the page should be {message}")]
public string TextOfMessageHeadingShouldBe()
{
- return _application.Browser.Element("message").Text;
+ return _application.Driver.FindElement(By.Id("message")).Text;
}
}
}
@@ -45,7 +45,7 @@ public string DownloadImage(string name)
var client = new WebClient();
var bytes = client.DownloadData("http://localhost" + url);
- StoryTellerAssert.Fail(bytes.Length < 500, "Not enough data detected for the image. Did it really load?");
+ StoryTellerAssert.Fail(bytes.Length < 100, "Not enough data detected for the image. Did it really load?");
return client.ResponseHeaders[HttpResponseHeader.ContentType];
}
Oops, something went wrong. Retry.

0 comments on commit 212ea84

Please sign in to comment.