Esempio n. 1
0
        /// <summary>
        /// Runs the test in given assembly against the provided source assembly.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="TestResult"/>.
        /// </returns>
        public TestResult RunTests(TestRunRequest request)
        {
            Uri uri = new Uri(request.TestAssembly.CodeBase);
            this.localDirectory = Path.GetDirectoryName(uri.LocalPath);
            this.engine = TestEngineActivator.CreateInstance(null, InternalTraceLevel.Off);

            var settings = new Dictionary<string, object>();

            var runner = new DefaultTestAssemblyRunner(new DefaultTestAssemblyBuilder());
            runner.Load(request.TestAssembly, settings);

            // Convert our own framework XmlNode to a TestEngineResult
            var package = new TestPackage(this.GetLocalPath(uri.AbsolutePath));

            this.engineResult = TestEngineResult.MakeTestRunResult(
                package,
                DateTime.Now,
                new TestEngineResult(
                    runner.Run(TestListener.NULL, NUnit.Framework.Internal.TestFilter.Empty).ToXml(true).OuterXml));

            return this.SummaryTransformTest();
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the assembly that contains tests and run the tests.
        /// </summary>
        /// <param name="testAssembly">
        /// Assembly that will be containing tests
        /// </param>
        private void LoadTestAndRunningAssembly(Assembly testAssembly)
        {
            Uri uri = new Uri(testAssembly.CodeBase);
            this.localDirectory = Path.GetDirectoryName(uri.LocalPath);
            this.engine = TestEngineActivator.CreateInstance(null, InternalTraceLevel.Off);

            var settings = new Dictionary<string, object>();

            var runner = new DefaultTestAssemblyRunner(new DefaultTestAssemblyBuilder());
            Assert.True(runner.Load(testAssembly, settings), "Unable to load Executing Assembly.");

            // Convert our own framework XmlNode to a TestEngineResult
            var package = new TestPackage(this.GetLocalPath(uri.AbsolutePath));

            this.engineResult = TestEngineResult.MakeTestRunResult(
                package,
                DateTime.Now,
                new TestEngineResult(
                    runner.Run(TestListener.NULL, NUnit.Framework.Internal.TestFilter.Empty).ToXml(true).OuterXml));
        }