Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ Thumbs.db
_compareTemp
_notes
aspnet_client
httpd.parse.errors
httpd.parse.errors
/MvcMegaForms/.vs/
67 changes: 39 additions & 28 deletions MvcMegaForms/MVCMega.Forms.FunctionalTests/AssemblyFixture.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
// /*
// Copyright (c) 2012 Andrew Newton (http://about.me/nootn)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// */

using NUnit.Framework;
using TestStack.Seleno.Configuration;
using TestStack.Seleno.Configuration.Screenshots;

namespace MVCMega.Forms.FunctionalTests
{
[SetUpFixture]
public class AssemblyFixture
{
[SetUp]
public void SetUp()
{
SelenoApplicationRunner.Run(
"MvcMega.Forms.WebsiteForTesting",
12121,
c => c.UsingCamera(new FileCamera("SCREENSHOTS")));
}
}
// /*
// Copyright (c) 2012 Andrew Newton (http://about.me/nootn)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// */

using NUnit.Framework;
using TestStack.Seleno.Configuration;
using TestStack.Seleno.Configuration.Screenshots;

namespace MVCMega.Forms.FunctionalTests
{


[SetUpFixture]
public class AssemblyFixture
{
public static class Host
{
public static readonly SelenoHost Instance = new SelenoHost();

static Host()
{
Instance.Run(
"MvcMega.Forms.WebsiteForTesting",
12121,
c => c.WithRemoteWebDriver(BrowserFactory.Chrome).UsingCamera(new FileCamera("SCREENSHOTS")));
}
}

[SetUp]
public void SetUp()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,60 @@
// /*
// Copyright (c) 2012 Andrew Newton (http://about.me/nootn)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// */

using MVCMega.Forms.FunctionalTests.Pages;
using MVCMega.Forms.FunctionalTests.Pages.ChangeVisually;
using MvcMega.Forms.WebsiteForTesting.Models.ChangeVisuallyScreens;
using NUnit.Framework;
using OpenQA.Selenium;
using TestStack.BDDfy;
using TestStack.BDDfy.Core;
using TestStack.BDDfy.Scanners.StepScanners.Fluent;

namespace MVCMega.Forms.FunctionalTests.ChangeVisually
{
[TestFixture]
[Story(AsA = "As a user",
IWant = "I want to hide and show fields based on ticking and un-ticking check boxes",
SoThat = "So that my forms will be awesome")]
public class CheckboxFieldsCanBeHookedUp
{
private CheckboxPage _page;

private void GivenUserIsOnTheCheckboxPage()
{
_page = new HomePage()
.GoToCheckboxPage();
}

private void WhenShowNextFieldIsChecked()
{
var model = new CheckboxModel();
model.TickCheckboxToShowNextField = true;
_page.FillSingleForm(model);
}

private void ThenNextFieldIsShown()
{
var elem = _page.AssertThatElements(By.Id("NextField"));

//TODO: assert that elem exists and is not hidden (I.e. check html attributes..)

//Mehdi, could there be a nicer way to get the ID? We know the model type.. so something like:
//var elem = _homePage.GetElementByModelProperty(m => m.NextField).
}

[Test]
public void SetCheckboxFromUntickedToTicked()
{
this.Given(_ => _.GivenUserIsOnTheCheckboxPage())
.When(_ => _.WhenShowNextFieldIsChecked())
.Then(_ => _.ThenNextFieldIsShown())
.BDDfy();
}
}
// /*
// Copyright (c) 2012 Andrew Newton (http://about.me/nootn)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// */

using MVCMega.Forms.FunctionalTests.Pages;
using MVCMega.Forms.FunctionalTests.Pages.ChangeVisually;
using MvcMega.Forms.WebsiteForTesting.Models.ChangeVisuallyScreens;
using NUnit.Framework;
using OpenQA.Selenium;
using TestStack.BDDfy;
using TestStack.BDDfy.Core;
using TestStack.BDDfy.Scanners.StepScanners.Fluent;

namespace MVCMega.Forms.FunctionalTests.ChangeVisually
{
[TestFixture]
[Story(AsA = "As a user",
IWant = "I want to hide and show fields based on ticking and un-ticking check boxes",
SoThat = "So that my forms will be awesome")]
public class CheckboxFieldsCanBeHookedUp
{
private CheckboxPage _page;

private void GivenUserIsOnTheCheckboxPage()
{
_page = AssemblyFixture.Host.Instance.NavigateToInitialPage<HomePage>()
.GoToCheckboxPage();
}

private void WhenShowNextFieldIsChecked()
{
var model = new CheckboxModel();
model.TickCheckboxToShowNextField = true;
_page.FillSingleForm(model);
}

private void ThenNextFieldIsShown()
{
Assert.True(_page.NextField.Displayed);

//Mehdi, could there be a nicer way to get the ID? We know the model type.. so something like:
//var elem = _homePage.GetElementByModelProperty(m => m.NextField).
}

[Test]
public void SetCheckboxFromUntickedToTicked()
{
this.Given(_ => _.GivenUserIsOnTheCheckboxPage())
.When(_ => _.WhenShowNextFieldIsChecked())
.Then(_ => _.ThenNextFieldIsShown())
.BDDfy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using MvcMega.Forms.WebsiteForTesting.Models.ChangeVisuallyScreens;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.Events;
using TestStack.BDDfy;
using TestStack.BDDfy.Core;
using TestStack.BDDfy.Scanners.StepScanners.Fluent;
Expand All @@ -28,46 +29,41 @@ public class TextboxFieldsCanBeHookedUp
{
private TextboxPage _page;

private void GivenUserIsOnTheCheckboxPage()
private void GivenUserIsOnTheTextboxPage()
{
_page = new HomePage()
_page = AssemblyFixture.Host.Instance.NavigateToInitialPage<HomePage>()
.GoToTextboxPage();
}

private void WhenMakeNotEmptyToShowNextField1IsEmptyInitially()
{
var model = new TextboxModel();
model.MakeNotEmptyToShowNextField1 = string.Empty;
_page.FillSingleForm(model);
_page.MakeNotEmptyToShowNextField1.SendKeys("SomeValue\t");

_page.ClearMakeNotEmptyToShowNextField1();
}

private void WhenMakeNotEmptyToShowNextField1IsNotEmpty()
{
var model = new TextboxModel();
model.MakeNotEmptyToShowNextField1 = "something";
_page.FillSingleForm(model);
_page.ClearMakeNotEmptyToShowNextField1();
_page.MakeNotEmptyToShowNextField1.SendKeys("SomeValue\t");
}

private void ThenNextField1IsHidden()
{
//TODO: waiting on Seleno to get the element properly
var elem = _page.AssertThatElements(By.Id("NextField1"));
elem.Exist();
elem.ConformTo(i => Assert.IsTrue(i.All(a => a.GetCssValue("display") == "none")));
//TODO: waiting on Seleno to get the element properly
Assert.False(_page.NextField1.Displayed);
}

private void ThenNextField1IsShown()
{
//TODO: waiting on Seleno to get the element properly
var elem = _page.AssertThatElements(By.Id("NextField1"));
elem.Exist();
//elem.ConformTo(i => Assert.IsTrue(i.All(a => a.FindElement(new By.jQueryBy("").Parent(".form-group")).GetCssValue("display") == "block")));
//TODO: waiting on Seleno to get the element properly
Assert.True(_page.NextField1.Displayed);
}

[Test]
public void SetTextboxToEmptyToHideNextValue()
{
this.Given(_ => _.GivenUserIsOnTheCheckboxPage())
this.Given(_ => _.GivenUserIsOnTheTextboxPage())
.When(_ => _.WhenMakeNotEmptyToShowNextField1IsEmptyInitially())
.Then(_ => _.ThenNextField1IsHidden())
.BDDfy();
Expand All @@ -76,7 +72,7 @@ public void SetTextboxToEmptyToHideNextValue()
[Test]
public void SetTextboxToNotEmptyToShowNextValue()
{
this.Given(_ => _.GivenUserIsOnTheCheckboxPage())
this.Given(_ => _.GivenUserIsOnTheTextboxPage())
.When(_ => _.WhenMakeNotEmptyToShowNextField1IsNotEmpty())
.Then(_ => _.ThenNextField1IsShown())
.BDDfy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -36,9 +38,8 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Castle.Core.3.1.0\lib\net40-client\Castle.Core.dll</HintPath>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -56,8 +57,10 @@
<HintPath>..\packages\NUnit.2.6.1\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web.Helpers">
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.Helpers.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -87,17 +90,17 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TestStack.BDDfy, Version=3.12.0.0, Culture=neutral, PublicKeyToken=a357057d05a879bd, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\TestStack.BDDfy.3.12\lib\NET40\TestStack.BDDfy.dll</HintPath>
<Reference Include="TestStack.BDDfy, Version=3.13.0.0, Culture=neutral, PublicKeyToken=a357057d05a879bd, processorArchitecture=MSIL">
<HintPath>..\packages\TestStack.BDDfy.3.13\lib\NET40\TestStack.BDDfy.dll</HintPath>
</Reference>
<Reference Include="TestStack.Seleno, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\TestStack.Seleno.0.2\lib\NET40\TestStack.Seleno.dll</HintPath>
<Reference Include="TestStack.Seleno, Version=0.9.61.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TestStack.Seleno.0.9.61\lib\NET40\TestStack.Seleno.dll</HintPath>
</Reference>
<Reference Include="WebDriver, Version=2.25.1.0, Culture=neutral, PublicKeyToken=1c2bd1631853048f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Selenium.WebDriver.2.25.1\lib\net40\WebDriver.dll</HintPath>
<Reference Include="WebDriver, Version=3.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.3.5.1\lib\net40\WebDriver.dll</HintPath>
</Reference>
<Reference Include="WebDriver.Support, Version=2.53.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.2.53.0\lib\net40\WebDriver.Support.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -136,6 +139,13 @@
<Content Include="BDDfy.readme.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Loading