Beispiel #1
0
        public void AddSameTestTwice()
        {
            var testSpec   = new TestSpec();
            var testMethod = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));

            testSpec.AddTest(testMethod);
            testSpec.AddTest(testMethod);
            Assert.Equals(1, testSpec.FixtureCount);
        }
Beispiel #2
0
        public void RunTwoOutOfThree()
        {
            var tc       = new TestFixture(typeof(Mock2));
            var testSpec = new TestSpec();
            var t        = typeof(Mock2);

            testSpec.AddTest(t.Assembly.FullName, t.FullName, "Test2");
            testSpec.AddTest(t.Assembly.FullName, t.FullName, "Test1");
            tc.Execute(testSpec, new NullListener());
            Assert.Equals("FixtureSetUpSetUpTest1CleanupSetUpTest2CleanupFixtureTearDown", _methodSequence);
        }
Beispiel #3
0
        public void NameReportedForSkippedMethod()
        {
            var fixture = new TestFixture(typeof(FixtureWithIgnoredMethod));

            var spec = new TestSpec();

            spec.AddTest(new TestMethod(fixture,
                                        typeof(FixtureWithIgnoredMethod).GetMethod("ATestMethod")));
            spec.AddTest(new TestMethod(fixture,
                                        typeof(FixtureWithIgnoredMethod).GetMethod("IgnoredMethodWithReason")));

            fixture.Execute(spec, new SimpleTestListener());
            Assert.Contains("csUnit.Core.Tests#"
                            + typeof(FixtureWithIgnoredMethod).FullName + "#"
                            + "IgnoredMethodWithReason#TheReason#",
                            SimpleTestListener.IgnoredItems);
        }
Beispiel #4
0
 public void OneTestConfigured() {
    var testSpec = new TestSpec();
    var testMethod1 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));
    var testMethod2 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Nope"));
    testSpec.AddTest(testMethod1);
    Assert.True(testSpec.Contains(testMethod1));
    Assert.False(testSpec.Contains(testMethod2));
 }
Beispiel #5
0
        public void CanSelectTestFixture()
        {
            var testSpec = new TestSpec();

            testSpec.AddTest(GetType().Assembly.GetName().Name,
                             typeof(MockTestMethod).FullName, string.Empty);
            Assert.True(testSpec.Contains(new MockTestMethod("Foo")));
        }
Beispiel #6
0
        public void RunOneTestOnly()
        {
            var testSpec = new TestSpec();
            var t        = typeof(ClassWithAttributes);

            testSpec.AddTest(t.Assembly.FullName, t.FullName, "FirstTestMethod");
            _tc.Execute(testSpec, new NullListener());
            Assert.Equals("SetUpMethodFirstTestMethodCleanupMethod", _methodSequence);
        }
Beispiel #7
0
        public void TestNameIsPrefixOfSecondTestNameViaITestMethod()
        {
            var testSpec = new TestSpec();

            testSpec.AddTest(GetType().Assembly.GetName().Name,
                             typeof(MockTestMethod).FullName, "Prefix");
            Assert.True(testSpec.Contains(new MockTestMethod("Prefix")));
            Assert.False(testSpec.Contains(new MockTestMethod("PrefixTestName")));
        }
Beispiel #8
0
        public void AssemblyIsConfiguredWithAtLeastOneTest()
        {
            var testSpec    = new TestSpec();
            var testFixture = new TestFixture(typeof(Foo));
            var testMethod  = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));

            testSpec.AddTest(testMethod.AssemblyName, testMethod.DeclaringTypeFullName, testMethod.Name);
            Assert.True(testSpec.Contains(testFixture));
        }
Beispiel #9
0
        public void TestNameIsPrefixOfSecondTestName()
        {
            var testSpec    = new TestSpec();
            var testMethod1 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Test1"));
            var testMethod2 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Test1AsPrefix"));

            testSpec.AddTest(testMethod1);
            Assert.True(testSpec.Contains(testMethod1));
            Assert.False(testSpec.Contains(testMethod2));
        }
Beispiel #10
0
        public void IgnoredTestIsNotRun()
        {
            var tc       = new TestFixture(typeof(Mock2));
            var testSpec = new TestSpec();
            var t        = typeof(Mock2);

            testSpec.AddTest(t.Assembly.FullName, t.FullName, "IgnoredTest");
            tc.Execute(testSpec, new NullListener());
            Assert.Equals("FixtureSetUpFixtureTearDown", _methodSequence);
        }
Beispiel #11
0
        public void TestNameIsPrefixOfSecondTestName()
        {
            var testSpec    = new TestSpec();
            var testFixture = new TestFixture(typeof(Foo));
            var testMethod  = new TestMethod(testFixture, typeof(Foo).GetMethod("Test1"));

            testSpec.AddTest(testMethod);
            testFixture.Execute(testSpec, new NullListener());
            Assert.Equals("Test1()", _methodSequence);
        }
Beispiel #12
0
        public void OneTestConfigured()
        {
            var testSpec    = new TestSpec();
            var testMethod1 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));
            var testMethod2 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Nope"));

            testSpec.AddTest(testMethod1);
            Assert.True(testSpec.Contains(testMethod1));
            Assert.False(testSpec.Contains(testMethod2));
        }
Beispiel #13
0
 public void IgnoredMethod() {
    MyListener myListener = new MyListener();
    TestFixture tc = new TestFixture(typeof(HasIgnoredMethod));
    TestSpec ts = new TestSpec();
    ts.AddTest("csUnit.Core.Tests", typeof(HasIgnoredMethod).FullName, string.Empty);
    tc.Execute(ts, myListener);
    Assert.Equals(1, myListener.SkipCount);
    // Skipped tests do not 'start'
    Assert.Equals(1, myListener.TestCount);
 }
Beispiel #14
0
        public void CanSelectNameSpace()
        {
            var testSpec        = new TestSpec();
            var nameSpaceName   = typeof(MockTestMethod).FullName;
            var indexOfFirstDot = nameSpaceName.IndexOf('.');

            nameSpaceName = nameSpaceName.Substring(0, indexOfFirstDot);
            testSpec.AddTest(GetType().Assembly.GetName().Name,
                             nameSpaceName, string.Empty);
            Assert.True(testSpec.Contains(new MockTestMethod("Foo")));
        }
Beispiel #15
0
        public void IgnoredMethod()
        {
            MyListener  myListener = new MyListener();
            TestFixture tc         = new TestFixture(typeof(HasIgnoredMethod));
            TestSpec    ts         = new TestSpec();

            ts.AddTest("csUnit.Core.Tests", typeof(HasIgnoredMethod).FullName, string.Empty);
            tc.Execute(ts, myListener);
            Assert.Equals(1, myListener.SkipCount);
            // Skipped tests do not 'start'
            Assert.Equals(1, myListener.TestCount);
        }
 public override void Execute(object sender, EventArgs args)
 {
     if (Recipe.Current != null)
     {
         TestSpec ts = new TestSpec();
         foreach (object item in CommandTarget.SelectedItems)
         {
             UiElementInfo uiElemInfo = item as UiElementInfo;
             if (uiElemInfo != null)
             {
                 ts.AddTest(uiElemInfo.TestSpecName);
             }
         }
         if (ts.FixtureCount > 0)
         {
             Recipe.Current.RunTests(ts);
         }
     }
 }
Beispiel #17
0
 public void AssemblyIsConfiguredWithAtLeastOneTest() {
    var testSpec = new TestSpec();
    var testFixture = new TestFixture(typeof(Foo));
    var testMethod = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));
    testSpec.AddTest(testMethod.AssemblyName, testMethod.DeclaringTypeFullName, testMethod.Name);
    Assert.True(testSpec.Contains(testFixture));
 }
Beispiel #18
0
 public void AddSameTestTwice() {
    var testSpec = new TestSpec();
    var testMethod = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));
    testSpec.AddTest(testMethod);
    testSpec.AddTest(testMethod);
    Assert.Equals(1, testSpec.FixtureCount);
 }
Beispiel #19
0
 public void TestNameIsPrefixOfSecondTestNameViaITestMethod() {
    var testSpec = new TestSpec();
    testSpec.AddTest(GetType().Assembly.GetName().Name,
       typeof(MockTestMethod).FullName, "Prefix");
    Assert.True(testSpec.Contains(new MockTestMethod("Prefix")));
    Assert.False(testSpec.Contains(new MockTestMethod("PrefixTestName")));
 }
Beispiel #20
0
 public void TestNameIsPrefixOfSecondTestName() {
    var testSpec = new TestSpec();
    var testMethod1 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Test1"));
    var testMethod2 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Test1AsPrefix"));
    testSpec.AddTest(testMethod1);
    Assert.True(testSpec.Contains(testMethod1));
    Assert.False(testSpec.Contains(testMethod2));
 }
Beispiel #21
0
 public void CanSelectNameSpace() {
    var testSpec = new TestSpec();
    var nameSpaceName = typeof(MockTestMethod).FullName;
    var indexOfFirstDot = nameSpaceName.IndexOf('.');
    nameSpaceName = nameSpaceName.Substring(0, indexOfFirstDot);
    testSpec.AddTest(GetType().Assembly.GetName().Name,
       nameSpaceName, string.Empty);
    Assert.True(testSpec.Contains(new MockTestMethod("Foo")));
 }
Beispiel #22
0
 public void CanSelectTestFixture() {
    var testSpec = new TestSpec();
    testSpec.AddTest(GetType().Assembly.GetName().Name,
       typeof(MockTestMethod).FullName, string.Empty);
    Assert.True(testSpec.Contains(new MockTestMethod("Foo")));
 }
Beispiel #23
0
      public void NameReportedForSkippedMethod() {
         var fixture = new TestFixture(typeof(FixtureWithIgnoredMethod));

         var spec = new TestSpec();

         spec.AddTest(new TestMethod(fixture,
            typeof(FixtureWithIgnoredMethod).GetMethod("ATestMethod")));
         spec.AddTest(new TestMethod(fixture,
            typeof(FixtureWithIgnoredMethod).GetMethod("IgnoredMethodWithReason")));

         fixture.Execute(spec, new SimpleTestListener());
         Assert.Contains("csUnit.Core.Tests#"
            + typeof(FixtureWithIgnoredMethod).FullName + "#"
            + "IgnoredMethodWithReason#TheReason#", 
            SimpleTestListener.IgnoredItems);
      }
Beispiel #24
0
 public void RunOneTestOnly() {
    var testSpec = new TestSpec();
    var t = typeof(ClassWithAttributes);
    testSpec.AddTest(t.Assembly.FullName, t.FullName, "FirstTestMethod");
    _tc.Execute(testSpec, new NullListener());
    Assert.Equals("SetUpMethodFirstTestMethodCleanupMethod", _methodSequence);
 }
Beispiel #25
0
 public void TestNameIsPrefixOfSecondTestName() {
    var testSpec = new TestSpec();
    var testFixture = new TestFixture(typeof(Foo));
    var testMethod = new TestMethod(testFixture, typeof(Foo).GetMethod("Test1"));
    testSpec.AddTest(testMethod);
    testFixture.Execute(testSpec, new NullListener());
    Assert.Equals("Test1()", _methodSequence);
 }
Beispiel #26
0
 public void IgnoredTestIsNotRun() {
    var tc = new TestFixture(typeof(Mock2));
    var testSpec = new TestSpec();
    var t = typeof(Mock2);
    testSpec.AddTest(t.Assembly.FullName, t.FullName,  "IgnoredTest");
    tc.Execute(testSpec, new NullListener());
    Assert.Equals("FixtureSetUpFixtureTearDown", _methodSequence);
 }
Beispiel #27
0
 public void RunTwoOutOfThree() {
    var tc = new TestFixture(typeof(Mock2));
    var testSpec = new TestSpec();
    var t = typeof(Mock2);
    testSpec.AddTest(t.Assembly.FullName, t.FullName, "Test2");
    testSpec.AddTest(t.Assembly.FullName, t.FullName, "Test1");
    tc.Execute(testSpec, new NullListener());
    Assert.Equals("FixtureSetUpSetUpTest1CleanupSetUpTest2CleanupFixtureTearDown", _methodSequence);
 }