Exemplo n.º 1
0
 public StateMachineViewModel Setup(TestContext testContext)
 {
     context = testContext;
     return(new StateMachineViewModel(() =>
     {
         QUnit.start();
         QUnit.ok(true);
         context.Dispose();
     }));
 }
        public EventViewModel Setup(TestContext context)
        {
            testContext = context;
            context.Element.Attribute("data-bind", "attach: { keydown: OnKeyDown }");

            return(new EventViewModel(() => {
                QUnit.start();
                QUnit.ok(true);
                context.Dispose();
            }));
        }
        static void Run() // HTML body.onload event entry point, see index.html
        {
            Binding.Init();

            var assembly = typeof(TestRunner).Assembly;

            foreach (var type in assembly.GetTypes())
            {
                var testAttribute = type.GetCustomAttributes(typeof(TestAttribute), false).Select(a => a as TestAttribute).FirstOrDefault();

                if (testAttribute != null)
                {
                    var methods = type.GetMethods();

                    var setup = methods.Single(m => m.GetCustomAttributes(typeof(TestSetup), false).Any());
                    var tests = methods.Where(m => m.GetCustomAttributes(typeof(TestMethodAttribute), false).Any());

                    foreach (var test in tests)
                    {
                        var name   = type.FullName + "." + test.Name;
                        var runner = new Action(() =>
                        {
                            var instance = type.GetConstructors()[0].Invoke(new object[0]);
                            TestHelper.TestFixture(testAttribute.Tag, testAttribute.Convention, (selector, c) => setup.Invoke(instance, new [] { new TestContext(selector, c), }), () => test.Invoke(instance, new object[0]));
                        });

                        if (testAttribute.Async)
                        {
                            QUnit.asyncTest(name, runner);
                        }
                        else
                        {
                            QUnit.test(name, runner);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 public static void Throws <T>(Action block)
     where T : Exception
 {
     QUnit.throws(block, (error) => typeof(T).IsAssignableFrom(error.GetType()));
 }
 public void It_should_have_rendered_correct_view()
 {
     QUnit.equal(context.Element.Html(), expected);
     Clean();
 }
Exemplo n.º 6
0
 public void It_should_have_correct_reference()
 {
     QUnit.ok(!context.Element.Is(":enabled"));
     context.Dispose();
 }
Exemplo n.º 7
0
 public void It_should_have_correct_reference()
 {
     context.Element.Click();
     QUnit.ok(model.Success);
     context.Dispose();
 }