public void Init()
        {
            m_Tests.Add(new MethodTest(TimeSpan.FromMilliseconds(10), m_DummyType.GetMethod("Method2"), result:"test", instance: new ObjectInstance(new DummyType(), new ObjectCreationData(m_DummyType.GetConstructor(Type.EmptyTypes)))));
            m_Tests.Add(new ExceptionThrowingTest(TimeSpan.FromMilliseconds(10), m_DummyType.GetMethod("Method1"), new InvalidOperationException(),
                new ObjectInstance(new DummyType(), new ObjectCreationData(m_DummyType.GetConstructor(Type.EmptyTypes)))));

            m_Tests.Add(new ConstructorTest(TimeSpan.FromMilliseconds(10), m_DummyType.GetConstructor(Type.EmptyTypes),
                                            result:new DummyType()));

            m_TestSuite = new TestSuite(m_DummyType, m_Tests);
            m_TestSuiteGenerator = new TestSuiteGenerator(m_TestSuite, new NUnitUnitTestCodeWriter());
        }
Beispiel #2
0
        private void AddTestSuiteToProject(TestSuite testSuite, Project testProject)
        {
            var unitTestsWriter = new NUnitUnitTestCodeWriter();
            var testSuiteGenerator = new TestSuiteGenerator(testSuite, unitTestsWriter, testProject.Name, "[TestFixture]");

            var testSuiteFilePath =
                Path.Combine(
            new string[]{
                testProject.FullName.Substring(0, testProject.FullName.LastIndexOf('\\')),
                                               testSuite.Type.FullName + ".Tests.cs"
            }
            );
            var file = File.Create(testSuiteFilePath);
            var streamWriter = new StreamWriter(file);
            streamWriter.Write(testSuiteGenerator.TransformText());
            streamWriter.Close();
            file.Close();

            var item =testProject.ProjectItems.AddFromFile(testSuiteFilePath);
            item.Open(Constants.vsViewKindCode);
            item.Document.Activate();
        }