Esempio n. 1
0
        public void AssemblyHasNoTestAssemblyFixture()
        {
            AssemblyFactory.Type = typeof(ATestAssembly);
            var ta = new TestAssembly(new AssemblyName("ATestAssembly"));

            ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
            Assert.Contains("TheOnlyTestInThisAssembly", SimpleTestListener.Messages);
        }
Esempio n. 2
0
        public void TestFixtureNestedInIgnoredTestFixture()
        {
            AssemblyFactory.Type = typeof(ASpecialAssembly);
            var assembly = new TestAssembly(new AssemblyName("bla"));

            assembly.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
            Assert.DoesNotContain("Bar", SimpleTestListener.Messages);
        }
Esempio n. 3
0
        public void IgnoredTestFixtureIsReported()
        {
            AssemblyFactory.Type = typeof(ASpecialAssembly);
            var assembly = new TestAssembly(new AssemblyName("bla"));

            assembly.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
            Assert.Contains(GetType().Assembly.FullName +
                            "#csUnit.Core.Tests.TestAssemblyTests+IgnoredFixture##Ignored for testing reasons.#",
                            SimpleTestListener.IgnoredItems);
        }
Esempio n. 4
0
        public void IgnoreAppliedOnlyAfterTestSpec()
        {
            AssemblyFactory.Type = typeof(ASpecialAssembly);
            var assembly = new TestAssembly(new AssemblyName("bla"));

            // The fixture is actually in category "Blue"!
            assembly.RunTests(new TestRun(new CategoryCriterion("Green")), new SimpleTestListener());

            Assert.Equals(0, SimpleTestListener.IgnoredItems.Length,
                          "Ignored tests that were not specified.");
        }
Esempio n. 5
0
        public void TearDownThrowsException()
        {
            var consoleOutput = new StringWriter();

            AssemblyFactory.Type = typeof(ATestAssembly);
            ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureThrowsInTearDown);
            var ta = new TestAssembly(new AssemblyName("ATestAssembly"));

            Console.SetOut(consoleOutput);
            ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
            var expected =
                "Executing " + GetType().FullName + @"+ATestAssembly+ATestClass.TheOnlyTestInThisAssembly()" + LineFeed +
                "Error: Exception thrown in TearDown method of TestAssemblyFixture:" + LineFeed +
                "       Assembly might not properly tear down used resources. Error details follow." + LineFeed +
                "Exception thrown in " + ATestAssembly.AssemblyFixtureType.FullName + @".TearDown()" + LineFeed;

            Assert.Contains(expected, consoleOutput.ToString());
        }
Esempio n. 6
0
        public void HasPrivateDefaultConstructorOnly()
        {
            var consoleOutput = new StringWriter();

            AssemblyFactory.Type = typeof(ATestAssembly);
            ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureWithPrivateConstructor);
            var ta = new TestAssembly(new AssemblyName("ATestAssembly"));

            Console.SetOut(consoleOutput);
            ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
            var expected =
                "Warning: no public parameterless constructor found for class:"
                + LineFeed +
                "         " + ATestAssembly.AssemblyFixtureType.FullName + LineFeed +
                "         TestAssemblyFixture will be ignored";

            Assert.Contains(expected, consoleOutput.ToString());
        }
Esempio n. 7
0
        public void SetUpThrowsException()
        {
            var consoleOutput = new StringWriter();

            AssemblyFactory.Type = typeof(ATestAssembly);
            ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureThrowsInSetUp);
            var ta = new TestAssembly(new AssemblyName("ATestAssembly"));

            Console.SetOut(consoleOutput);
            ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
            var expected =
                "Error: Exception thrown in SetUp method of TestAssemblyFixture:"
                + LineFeed +
                "       Tests depending on it might fail. Error details follow."
                + LineFeed +
                "Exception thrown in " + ATestAssembly.AssemblyFixtureType.FullName
                + @".SetUp()";

            Assert.Contains(expected, consoleOutput.ToString());
        }
Esempio n. 8
0
      public void IgnoreAppliedOnlyAfterTestSpec() {
         AssemblyFactory.Type = typeof(ASpecialAssembly);
         var assembly = new TestAssembly(new AssemblyName("bla"));

         // The fixture is actually in category "Blue"!
         assembly.RunTests(new TestRun(new CategoryCriterion("Green")), new SimpleTestListener());
         
         Assert.Equals(0, SimpleTestListener.IgnoredItems.Length,
            "Ignored tests that were not specified.");
      }
Esempio n. 9
0
 public void TestFixtureNestedInIgnoredTestFixture() {
    AssemblyFactory.Type = typeof(ASpecialAssembly);
    var assembly = new TestAssembly(new AssemblyName("bla"));
    assembly.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
    Assert.DoesNotContain("Bar", SimpleTestListener.Messages);
 }
Esempio n. 10
0
 public void IgnoredTestFixtureIsReported() {
    AssemblyFactory.Type = typeof(ASpecialAssembly);
    var assembly = new TestAssembly(new AssemblyName("bla"));
    assembly.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
    Assert.Contains(GetType().Assembly.FullName +
       "#csUnit.Core.Tests.TestAssemblyTests+IgnoredFixture##Ignored for testing reasons.#",
       SimpleTestListener.IgnoredItems);
 }
 public void TearDownThrowsException() {
    var consoleOutput = new StringWriter();
    AssemblyFactory.Type = typeof(ATestAssembly);
    ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureThrowsInTearDown);
    var ta = new TestAssembly(new AssemblyName("ATestAssembly"));
    Console.SetOut(consoleOutput);
    ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
    var expected =
       "Executing " + GetType().FullName + @"+ATestAssembly+ATestClass.TheOnlyTestInThisAssembly()" + LineFeed +
       "Error: Exception thrown in TearDown method of TestAssemblyFixture:" + LineFeed +
       "       Assembly might not properly tear down used resources. Error details follow." + LineFeed +
       "Exception thrown in " + ATestAssembly.AssemblyFixtureType.FullName + @".TearDown()" + LineFeed;
    Assert.Contains(expected, consoleOutput.ToString());
 }
 public void SetUpThrowsException() {
    var consoleOutput = new StringWriter();
    AssemblyFactory.Type = typeof(ATestAssembly);
    ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureThrowsInSetUp);
    var ta = new TestAssembly(new AssemblyName("ATestAssembly"));
    Console.SetOut(consoleOutput);
    ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
    var expected =
       "Error: Exception thrown in SetUp method of TestAssemblyFixture:"
       + LineFeed +
       "       Tests depending on it might fail. Error details follow."
       + LineFeed +
       "Exception thrown in " + ATestAssembly.AssemblyFixtureType.FullName
       + @".SetUp()";
    Assert.Contains(expected, consoleOutput.ToString());
 }
 public void HasPrivateDefaultConstructorOnly() {
    var consoleOutput = new StringWriter();
    AssemblyFactory.Type = typeof(ATestAssembly);
    ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureWithPrivateConstructor);
    var ta = new TestAssembly(new AssemblyName("ATestAssembly"));
    Console.SetOut(consoleOutput);
    ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
    var expected =
       "Warning: no public parameterless constructor found for class:"
       + LineFeed +
       "         " + ATestAssembly.AssemblyFixtureType.FullName + LineFeed +
       "         TestAssemblyFixture will be ignored";
    Assert.Contains(expected, consoleOutput.ToString());
 }
 public void AssemblyHasNoTestAssemblyFixture() {
    AssemblyFactory.Type = typeof(ATestAssembly);
    var ta = new TestAssembly(new AssemblyName("ATestAssembly"));
    ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener());
    Assert.Contains("TheOnlyTestInThisAssembly", SimpleTestListener.Messages);
 }