Permalink
Browse files

add Thread sleep in SimpleWebServer to let it start before trying to …

…hit it with the browser

add bat file to update lib 
update FluentWebUITesting.dll to latest
support Set().To() for dropdownlists
  • Loading branch information...
1 parent 467f599 commit ae186e6bd108a0ecf86f16ce074d07eb859e37dd @handcraftsman committed Feb 28, 2010
@@ -29,10 +29,10 @@ public class IntegrationTestRunner
public void Run(IEnumerable<Action<Browser>> browserActions, IEnumerable<Action<HttpMessage, ISocketProxy>> webServerResponses, string initialPage)
{
UITestRunner.InitializeBrowsers(x =>
- {
- x.CloseBrowserAfterEachTest = true;
- x.UseInternetExplorer = true;
- });
+ {
+ x.CloseBrowserAfterEachTest = true;
+ x.UseInternetExplorer = true;
+ });
var webServer = new SimpleWebServer(webServerResponses);
try
@@ -0,0 +1,15 @@
+<html>
+<body>
+
+<label>Label without for</label>
+<label for="missing">Label with incorrect for</label>
+
+<label for="ddlState">State</label>
+<select id="ddlState">
+ <option value="">(Select)</option>
+ <option value="NM">New Mexico</option>
+ <option value="TX">Texas</option>
+</select>
+
+</body>
+</html>
@@ -1,6 +1,9 @@
<html>
<body>
+<label>Label without for</label>
+<label for="missing">Label with incorrect for</label>
+
<label for="txtFirstName">First Name</label>
<input type="text" id="txtFirstName" />
@@ -1,8 +0,0 @@
-<html>
-<body>
-
-<label for="missing">First Name</label>
-<input type="text" id="txtFirstName" />
-
-</body>
-</html>
@@ -1,8 +0,0 @@
-<html>
-<body>
-
-<label>First Name</label>
-<input type="text" id="txtFirstName" />
-
-</body>
-</html>
@@ -0,0 +1,125 @@
+// Copyright 2010 Clinton Sheppard <sheppard@cs.unm.edu>
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using FluentAssert;
+
+using FluentWebUITesting;
+using FluentWebUITesting.Extensions;
+
+using gar3t.decuit;
+
+using NUnit.Framework;
+
+namespace decuit.Tests.Integration
+{
+ public partial class SetTests
+ {
+ [TestFixture]
+ public class When_asked_to_Set_the_value_of_a_DropDownList
+ {
+ private const string Expected = "Texas";
+ private const string LabelText = "State";
+ private const string PageName = "SetDropDownList.html";
+
+ [Test]
+ public void Should_fail_if_the_drop_down_does_not_have_a_matching_option_by_text_or_value()
+ {
+ const string badOption = "Ontario";
+ var browserActions = UITestRunner.InitializeWorkFlowContainer(
+ b => b.Set(LabelText).To(badOption)
+ );
+
+ var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
+ browserActions,
+ SimpleWebServer.InitializeServerResponsesContainer(),
+ PageName));
+
+ exception.Message.Contains(badOption).ShouldBeTrue();
+ }
+
+ [Test]
+ public void Should_fail_if_the_label_text_does_not_exist()
+ {
+ const string textOfBadLabel = "Country";
+ var browserActions = UITestRunner.InitializeWorkFlowContainer(
+ b => b.Set(textOfBadLabel).To(Expected)
+ );
+
+ var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
+ browserActions,
+ SimpleWebServer.InitializeServerResponsesContainer(),
+ PageName));
+ exception.Message.Contains(textOfBadLabel).ShouldBeTrue();
+ }
+
+ [Test]
+ public void Should_fail_if_the_matching_label_does_not_have_a_For_attribute()
+ {
+ const string textOfBadLabel = "Label without for";
+ var browserActions = UITestRunner.InitializeWorkFlowContainer(
+ b => b.Set(textOfBadLabel).To(Expected)
+ );
+
+ var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
+ browserActions,
+ SimpleWebServer.InitializeServerResponsesContainer(),
+ PageName));
+ exception.Message.Contains(textOfBadLabel).ShouldBeTrue();
+ }
+
+ [Test]
+ public void Should_fail_if_the_matching_labels_For_attribute_refers_to_a_missing_control()
+ {
+ const string textOfBadLabel = "Label with incorrect for";
+ var browserActions = UITestRunner.InitializeWorkFlowContainer(
+ b => b.Set(textOfBadLabel).To(Expected)
+ );
+
+ var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
+ browserActions,
+ SimpleWebServer.InitializeServerResponsesContainer(),
+ PageName));
+ exception.Message.Contains(textOfBadLabel).ShouldBeTrue();
+ }
+
+ [Test]
+ public void Should_succeed_if_drop_down_has_an_option_with_matching_text()
+ {
+ var browserActions = UITestRunner.InitializeWorkFlowContainer(
+ b => b.Set(LabelText).To(Expected),
+ b => b.DropDownListWithId("ddlState").GetSelectedText().ShouldBeEqualTo(Expected)
+ );
+
+ new IntegrationTestRunner().Run(
+ browserActions,
+ SimpleWebServer.InitializeServerResponsesContainer(),
+ PageName);
+ }
+
+ [Test]
+ public void Should_succeed_if_drop_down_has_an_option_with_matching_value()
+ {
+ var browserActions = UITestRunner.InitializeWorkFlowContainer(
+ b => b.Set(LabelText).To("NM"),
+ b => b.DropDownListWithId("ddlState").GetSelectedText().ShouldBeEqualTo("New Mexico")
+ );
+
+ new IntegrationTestRunner().Run(
+ browserActions,
+ SimpleWebServer.InitializeServerResponsesContainer(),
+ PageName);
+ }
+ }
+ }
+}
@@ -15,71 +15,80 @@
using FluentAssert;
using FluentWebUITesting;
+using FluentWebUITesting.Extensions;
using gar3t.decuit;
using NUnit.Framework;
namespace decuit.Tests.Integration
{
- public class SetTests
+ public partial class SetTests
{
[TestFixture]
public class When_asked_to_Set_the_value_of_a_TextBox
{
+ private const string Expected = "James";
+ private const string LabelText = "First Name";
+ private const string PageName = "SetTextBox.html";
+
[Test]
public void Should_fail_if_the_label_text_does_not_exist()
{
+ const string textOfBadLabel = "Last Name";
var browserActions = UITestRunner.InitializeWorkFlowContainer(
- b => b.Set("Last Name").To("James")
+ b => b.Set(textOfBadLabel).To(Expected)
);
var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
browserActions,
SimpleWebServer.InitializeServerResponsesContainer(),
- "SetTextBox.html"));
- exception.Message.Contains("Last Name").ShouldBeTrue();
+ PageName));
+ exception.Message.Contains(textOfBadLabel).ShouldBeTrue();
}
[Test]
public void Should_fail_if_the_matching_label_does_not_have_a_For_attribute()
{
+ const string textOfBadLabel = "Label without for";
var browserActions = UITestRunner.InitializeWorkFlowContainer(
- b => b.Set("Last Name").To("James")
+ b => b.Set(textOfBadLabel).To(Expected)
);
var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
browserActions,
SimpleWebServer.InitializeServerResponsesContainer(),
- "SetTextbox_LabelWithoutFor.html"));
- exception.Message.Contains("Last Name").ShouldBeTrue();
+ PageName));
+ exception.Message.Contains(textOfBadLabel).ShouldBeTrue();
}
[Test]
public void Should_fail_if_the_matching_labels_For_attribute_refers_to_a_missing_control()
{
+ const string textOfBadLabel = "Label with incorrect for";
var browserActions = UITestRunner.InitializeWorkFlowContainer(
- b => b.Set("Last Name").To("James")
+ b => b.Set(textOfBadLabel).To(Expected)
);
var exception = Assert.Throws<AssertionException>(() => new IntegrationTestRunner().Run(
browserActions,
SimpleWebServer.InitializeServerResponsesContainer(),
- "SetTextbox_LabelWithForPointedToMissingControl.html"));
- exception.Message.Contains("Last Name").ShouldBeTrue();
+ PageName));
+ exception.Message.Contains(textOfBadLabel).ShouldBeTrue();
}
[Test]
public void Should_succeed_if_the_label_text_and_for_attribute_match()
{
var browserActions = UITestRunner.InitializeWorkFlowContainer(
- b => b.Set("First Name").To("James")
+ b => b.Set(LabelText).To(Expected),
+ b => b.TextBoxWithId("txtFirstName").Text().ShouldBeEqualTo(Expected)
);
new IntegrationTestRunner().Run(
browserActions,
SimpleWebServer.InitializeServerResponsesContainer(),
- "SetTextBox.html");
+ PageName);
}
}
}
@@ -17,6 +17,7 @@
using System.Linq;
using System.Net.Sockets;
using System.Text;
+using System.Threading;
using gar3t.Common;
using gar3t.Common.Extensions;
@@ -74,6 +75,7 @@ public void Run()
_stepIndex = 0;
_tcp = new Tcp();
_tcp.Listen(Port, ProcessClientRequest);
+ Thread.Sleep(100); // let server start
}
public void Stop()
@@ -69,10 +69,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="SetTests_DropDownList.cs" />
<Compile Include="InsufficientHttpMessageHandlingStepsException.cs" />
<EmbeddedResource Include="Pages\SetTextBox.html" />
<Compile Include="IntegrationTestRunner.cs" />
- <Compile Include="SetTests.cs" />
+ <Compile Include="SetTests_TextBox.cs" />
<Compile Include="SimpleWebServer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@@ -83,10 +84,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="Pages\SetTextbox_LabelWithoutFor.html" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="Pages\SetTextbox_LabelWithForPointedToMissingControl.html" />
+ <EmbeddedResource Include="Pages\SetDropDownList.html" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Oops, something went wrong.

0 comments on commit ae186e6

Please sign in to comment.