public override void SetUp()
        {
            base.SetUp();

            AddCodeFile("test.cs", @"
using NUnit.Framework;
namespace MyTests {
	class A {
		class InnerATest {
			[Test]
			public void FooBar() {}
		}
	}
}
");

            // The members should be changed on the existing TestClass instance,
            // so grab the reference in before updating.
            innerTestClass = testProject.GetTestClass(new FullTypeName("MyTests.A+InnerATest"));

            UpdateCodeFile("test.cs", @"
using NUnit.Framework;
namespace MyTests {
	class A {
		class InnerATest {
			[Test]
			public void FooBarRenamed() {}
			
			[TestFixture]
			class InnerInnerTest {}
		}
	}
}
");
        }
Пример #2
0
        public override void SetUp()
        {
            base.SetUp();
            AddCodeFile("test.cs", @"
using NUnit.Framework;
namespace MyTests {
	class A {
		class InnerTest {
			[Test]
			public void M() {}
		}
	}
}
");

            originalA = testProject.GetTestClass(new FullTypeName("MyTests.A"));

            UpdateCodeFile("test.cs", @"
using NUnit.Framework;
namespace MyTests {
	class A {
		class InnerTestMod {
			[Test]
			public void M() {}
		}
	}
}
");
        }
Пример #3
0
        public void AddClassWithTestFixtureAttribute()
        {
            // Add new compilation unit with extra class.
            AddCodeFileInNamespace("test.cs", "[TestFixture] class MyTestFixture {}");

            NUnitTestClass testClass = (NUnitTestClass)testProject.NestedTests.Single();

            Assert.AreEqual("RootNamespace.MyTestFixture", testClass.ReflectionName);
        }
Пример #4
0
        public override void SetUp()
        {
            base.SetUp();
            AddCodeFile("file1.cs", program);

            myTestFixture = (NUnitTestClass)testProject.NestedTests.Single();
            myTestFixture.EnsureNestedTestsInitialized();

            AddCodeFile("file2.cs", program);
        }
Пример #5
0
 public override void SetUp()
 {
     base.SetUp();
     AddCodeFileInNamespace("base1.cs", "class Base1 { [Test] public void Base1Test() {} }");
     AddCodeFileInNamespace("base2.cs", "class Base2 { [Test] public void Base2Test() {} }");
     AddCodeFileInNamespace("middle.cs", "class Middle : Base1 { }");
     AddCodeFileInNamespace("derived.cs", "[TestFixture] class Derived : Middle { }");
     testProject.EnsureNestedTestsInitialized();
     derived = testProject.NestedTests.OfType <NUnitTestClass>().Single(c => c.ClassName == "Derived");
     derived.EnsureNestedTestsInitialized();
 }
Пример #6
0
        public void TestInnerClassSpecifiedInInitialize()
        {
            NUnitTestClass          innerTestClass = new NUnitTestClass(testProject, new FullTypeName("MyTests.TestFixture+InnerTest"));
            NUnitConsoleApplication app            = new NUnitConsoleApplication(new [] { innerTestClass });

            app.NoLogo          = false;
            app.ShadowCopy      = true;
            app.NoXmlOutputFile = false;

            string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" " +
                                         "/run=\"MyTests.TestFixture+InnerTest\"";

            Assert.AreEqual(expectedCommandLine, app.GetArguments());
        }
        public override void SetUp()
        {
            base.SetUp();
            AddCodeFile("test.cs", @"using NUnit.Framework;
namespace RootNamespace.Tests {
	[TestFixture]
	class MyTestFixture {
		[Test] public void TestMethod1() {}
		[Test] public void TestMethod2() {}
	}
}");
            testClass   = testProject.GetTestClass(new FullTypeName("RootNamespace.Tests.MyTestFixture"));
            testMethod1 = testClass.FindTestMethod("TestMethod1");
            testMethod2 = testClass.FindTestMethod("TestMethod2");
        }
        public override void SetUp()
        {
            base.SetUp();

            AddCodeFileInNamespace("base.cs", @"
[TestFixture] class TestFixtureBase {
	[Test] public void BaseMethod() {}
}");
            AddCodeFileInNamespace("derived.cs", @"
[TestFixture] class MyTestFixture : TestFixtureBase {
	[Test] public void DerivedMethod() {}
}");
            testClass = testProject.GetTestClass(new FullTypeName("RootNamespace.MyTestFixture"));
            testClass.EnsureNestedTestsInitialized();
        }
        public override void SetUp()
        {
            base.SetUp();
            resultChangedCalled = false;
            AddCodeFile("test.cs", @"
using NUnit.Framework;
namespace RootNamespace.Tests {
	[TestFixture]
	class MyTestFixture {
		[Test]
		public void TestMethod() { }
	}
}");
            testClass  = (NUnitTestClass)testProject.NestedTests.Single().NestedTests.Single();
            testMethod = (NUnitTestMethod)testClass.NestedTests.Single();
        }
Пример #10
0
        public void AddTestFixtureAttributeToExistingClass()
        {
            // Create an old compilation unit with the test class
            // but without a [TestFixture] attribute.
            AddCodeFileInNamespace("test.cs", "class MyTestFixture {}");

            Assert.IsEmpty(testProject.NestedTests);

            // Create a new compilation unit with the test class
            // having a [TestFixture] attribute.
            UpdateCodeFileInNamespace("test.cs", "[TestFixture] class MyTestFixture {}");

            NUnitTestClass testClass = (NUnitTestClass)testProject.NestedTests.Single();

            Assert.AreEqual("RootNamespace.MyTestFixture", testClass.ReflectionName);
        }
        public override void SetUp()
        {
            base.SetUp();

            AddCodeFileInNamespace("base.cs", @"
class BaseClass {
	[Test] public virtual void VirtualTestMethod() {}
	[Test] public virtual void VirtualNonOverriddenTestMethod() {}
}");
            AddCodeFileInNamespace("derived.cs", @"
class DerivedClass : BaseClass {
	[Test] public override void VirtualTestMethod() {}
}");
            baseClass               = testProject.NestedTests.Cast <NUnitTestClass>().Single(c => c.ClassName == "BaseClass");
            derivedClass            = testProject.NestedTests.Cast <NUnitTestClass>().Single(c => c.ClassName == "DerivedClass");
            derivedClassMethodNames = derivedClass.NestedTests.Cast <NUnitTestMethod>().Select(m => m.MethodNameWithDeclaringTypeForInheritedTests).ToList();
        }
        public override void SetUp()
        {
            base.SetUp();
            AddCodeFileInNamespace("base.cs", @"
abstract class MyTestFixtureBase {
	[Test] public void MyTest() {}
	[Test] public void MyTest() {}
}");
            AddCodeFileInNamespace("derived.cs", @"
class MyTestFixture : MyTestFixtureBase {
	[Test] public void MyTest() {}
	[Test] public void MyTest() {}
}");
            testClass     = testProject.NestedTests.Cast <NUnitTestClass>().Single(c => c.ClassName == "MyTestFixture");
            baseMethod    = testClass.FindTestMethod("MyTestFixtureBase.MyTest");
            derivedMethod = testClass.FindTestMethod("MyTest");
        }
Пример #13
0
        public void XmlOutputFileNameSpecifiedOnCommandLine()
        {
            UnitTestingOptions options = new UnitTestingOptions(new Properties());

            options.CreateXmlOutputFile = true;
            NUnitTestClass          testFixture = new NUnitTestClass(testProject, new FullTypeName("MyTests.TestFixture.MyTest"));
            NUnitConsoleApplication app         = new NUnitConsoleApplication(new[] { testFixture }, options);

            app.NoLogo     = false;
            app.ShadowCopy = true;

            string expectedCommandLine =
                "\"C:\\Projects\\MyTests\\MyTests.dll\" " +
                "/xml=\"C:\\Projects\\MyTests\\MyTests-TestResult.xml\" " +
                "/run=\"MyTests.TestFixture.MyTest\"";

            Assert.AreEqual(expectedCommandLine, app.GetArguments());
        }
        public override void SetUp()
        {
            base.SetUp();
            AddCodeFileInNamespace("derived.cs", @"
[TestFixture]
public class CecilLayerTests : ReflectionOrCecilLayerTests
{ }");
            AddCodeFileInNamespace("base.cs", @"
public abstract class ReflectionOrCecilLayerTests {
	[Test]
	public void InheritanceTests() {}
	
	public void NonTestMethod() {}
}
");
            testProject.EnsureNestedTestsInitialized();
            cecilLayer  = testProject.NestedTests.Cast <NUnitTestClass>().Single(c => c.ClassName == "CecilLayerTests");
            testMembers = cecilLayer.NestedTests.Cast <NUnitTestMethod>().Select(m => m.MethodNameWithDeclaringTypeForInheritedTests).ToList();
        }
        public override void SetUp()
        {
            base.SetUp();
            classesAdded   = new List <NUnitTestClass>();
            classesRemoved = new List <NUnitTestClass>();

            // Create a project.
            AddCodeFile(mainFileName, @"using NUnit.Framework;
namespace RootNamespace {
	[TestFixture]
	class MyTestFixture {
		
	}
	class NonNUnitTestClass { }
}");

            testClass = testProject.GetTestClass(new FullTypeName("RootNamespace.MyTestFixture"));
            testProject.NestedTests.CollectionChanged += testProject_TestClasses_CollectionChanged;
        }
        public override void SetUp()
        {
            base.SetUp();
            AddCodeFile("test.cs", @"
using NUnit.Framework;
namespace MyTests {
	public class A
	{
		public class InnerATest
		{
			[Test]
			public void FooBar()
			{
			}
		}
	}
}");
            outerClass = testProject.GetTestClass(new FullTypeName("MyTests.A"));
            innerClass = testProject.GetTestClass(new FullTypeName("MyTests.A+InnerATest"));
        }
 protected List <string> GetTestMethodNames(NUnitTestClass testClass)
 {
     return(testClass.NestedTests.OfType <NUnitTestMethod>().Select(m => m.MethodNameWithDeclaringTypeForInheritedTests).ToList());
 }