#region Stormwind License Header // Copyright 2006-2008 Stormwind Project - http://www.stormwindproject.org/ // // Licensed under the Open Software License ("OSL") v. 3.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.opensource.org/licenses/osl-3.0.php // // 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. #endregion using System.IO; using NUnit.Framework; using Stormwind.Accuracy.Core; using Stormwind.Accuracy.Core.Config; using Stormwind.Accuracy.Core.PageModel; namespace Stormwind.Fjords.Infrastructure.Testing { public abstract class JsUnitTestFixture : AcceptanceTestFixture { [Test] public void ShouldRunTests() { //Context.Current.DebugMode = true; Context.Current.ElementNamingStrategy = new CustomNamingStrategy(); var story = Story .AsA("Web Site User") .IWantTo("Unit test JavaScript using the " + TestPageUrl + " Page") .SoThat("I can verify that my JavaScript code is correct"); var url = Path.Combine(Context.Current.RootUrl, "UnitTests/" + TestPageUrl); story.WithScenario("The tests run") .Given(I.GoTo("Js Unit Test Runner Page")) .And(I.AmIn("Main Frame>Main Data").Frame) .When(I.Fill.TextBox("Test File Name").With(url)) .And(I.Click("Run Button").Button) .Then(I.AmIn("Main Frame>Main Status").Frame) .And(I.WaitFor("Status: Done").Message) .And(I.AmIn("Main Frame>Main Counts>Main Counts Errors").Frame) .And(I.See("Errors: 0").Message) .And(I.AmIn("Main Frame>Main Counts>Main Counts Failures").Frame) .And(I.See("Failures: 0").Message); } public abstract string TestPageUrl { get;} } internal class CustomNamingStrategy : INamingStrategy { public string Resolve(ElementType type, string key) { return string.Join(string.Empty, key.Split(' ')); } } }