public NewTestResultSummaryEventArgs(ITest test, ITestResult result, ITestOutcomeFilter outcomeFilter, ITestResultSummary summary)
 {
     Test = test;
     Result = result;
     OutcomeFilter = outcomeFilter;
     Summary = summary;
 }
Example #2
0
        public void AddTest(ITest test)
        {
            if(test == null) throw new ArgumentNullException("test");

            tests.Add(test);
            test.TestCompleted += TestOnTestCompleted;
        }
        public OrganizationService(ITest test)
        {
            if(test == null)
                throw new ArgumentNullException("test");

            this._test = test;
        }
Example #4
0
 /// <summary>
 /// Forwards the TestStarted event to all listeners.
 /// </summary>
 /// <param name="test">The test that just started.</param>
 public void TestStarted(ITest test)
 {
     System.Diagnostics.Debug.WriteLine(test.Name + " TEST STARTED");
     System.Threading.Thread.Sleep(2000);
     foreach (TestListener listener in listeners)
         listener.TestStarted(test);
 }
Example #5
0
        private void Execute(ITest test, string methodPrefix)
        {
            var method = Reflect.GetNamedMethod(_ActionInterfaceType, methodPrefix + "Test");
            var details = CreateTestDetails(test);

            Reflect.InvokeMethod(method, _Action, details);
        }
Example #6
0
        public static void RunTest(TestType type, int ThreadCount, CallbackFunction callBack, ITest target)
        {
            for (int i = 0; i < ThreadCount; i++)
            {
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (object sender, DoWorkEventArgs e) =>
                {
                    bool result = target.Test();
                    e.Result = result;

                };

                worker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
                    {
                        if (callBack != null)
                        {
                            if (e.Error != null)
                            {
                                callBack(type, (bool)e.Result);
                            }
                            else
                            {
                                callBack(type, false);
                            }
                        }
                    };
                worker.RunWorkerAsync();
            }
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NUnitTestRunner"/> class.
 /// </summary>
 /// <param name="testData">The test data.</param>
 public NUnitTestRunner(NUnitTestData testData)
 {
     _nunittest = testData;
     string nunitsuite = testData.Class + "," + testData.Assembly;
     _suite = GetSuite(nunitsuite);
     testData.Suite = _suite;
 }
        public static void Queue(
            this IMessageBus messageBus,
            ITest test,
            Func<ITest, IMessageSinkMessage> createTestResultMessage,
            CancellationTokenSource cancellationTokenSource)
        {
            Guard.AgainstNullArgument("messageBus", messageBus);
            Guard.AgainstNullArgument("createTestResultMessage", createTestResultMessage);
            Guard.AgainstNullArgument("cancellationTokenSource", cancellationTokenSource);

            if (!messageBus.QueueMessage(new TestStarting(test)))
            {
                cancellationTokenSource.Cancel();
            }
            else
            {
                if (!messageBus.QueueMessage(createTestResultMessage(test)))
                {
                    cancellationTokenSource.Cancel();
                }
            }

            if (!messageBus.QueueMessage(new TestFinished(test, 0, null)))
            {
                cancellationTokenSource.Cancel();
            }
        }
 /// <summary>
 /// Writes test info to a file
 /// </summary>
 /// <param name="test">The test to be written</param>
 /// <param name="outputPath">Path to the file to which the test info is written</param>
 public void WriteTestFile(ITest test, string outputPath)
 {
     using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
     {
         WriteTestFile(test, writer);
     }
 }
Example #10
0
		/// <summary>
		/// Check whether the filter matches a test
		/// </summary>
		/// <param name="test">The test to be matched</param>
		/// <returns>True if it matches, otherwise false</returns>
		public override bool Match( ITest test )
		{
            if (topLevel && test.RunState == RunState.Explicit)
                return false;

			return !baseFilter.Pass( test );
		}
		public void AddAllCategories( ITest test )
		{
			AddCategories( test );
			if ( test.IsSuite )
				foreach( ITest child in test.Tests )
					AddAllCategories( child );
		}
Example #12
0
 public static void UnloadTestDomain()
 {
     if ( testDomain != null )
         testDomain.Unload();
     loadedTest = null;
     testDomain = null;
 }
Example #13
0
 /// <summary>
 /// Called when a test has just started
 /// </summary>
 /// <param name="test">The test that is starting</param>
 public void TestStarted(ITest test)
 {
     if (test.IsSuite)
         TC_TestSuiteStarted(test.Name);
     else
         TC_TestStarted(test.Name);
 }
        public void BeforeTest(ITest test)
        {
            //Log.Write("START:" + test.FullName);
            if (!_configuration.GenerateReport) return;

            _start = DateTime.Now;
        }
 public void SetUp()
 {
     MethodInfo fakeTestMethod1 = this.GetType().GetMethod("FakeTestMethod1", BindingFlags.Instance | BindingFlags.NonPublic);
     this.fakeTest1 = new NUnitTestMethod(fakeTestMethod1);
     MethodInfo fakeTestMethod2 = this.GetType().GetMethod("FakeTestMethod2", BindingFlags.Instance | BindingFlags.NonPublic);
     this.fakeTest2 = new NUnitTestMethod(fakeTestMethod2);
 }
        private static void ExecuteEventExposureTest(string[] args) {                        
            _test = new XMLTest2(Path.Combine(GetExecutingDirectory(), args[0]), Path.Combine(GetExecutingDirectory(), args[1]));

            IResult result = _test.RunTest();

            DisplayOutput(result);
        }
 bool OnStart(XmlNode xml)
 {
     var testCase = FindTestCase(xml.Attributes["type"].Value, xml.Attributes["method"].Value);
     currentTest = new Xunit1Test(testCase, xml.Attributes["name"].Value);
     SendTestCaseMessagesWhenAppropriate(testCase);
     return messageSink.OnMessage(new TestStarting(currentTest)) && TestClassResults.Continue;
 }
        private static void ExecutePuzzleTest() {                       
            _test = new XMLTest1(Path.Combine(GetExecutingDirectory(), "puzzle1.xml"));

            IResult result = _test.RunTest();

            DisplayOutput(result);
        }
 public void TestStarted(ITest test)
 {
     level++;
     prefix = new string('>', level);
     if(options.DisplayTestLabels == "On" || options.DisplayTestLabels == "All")
         outWriter.WriteLine("{0} {1}", prefix, test.Name);
 }
Example #20
0
 /// <summary>
 /// Construct a TestNode given a TestResult
 /// </summary>
 public TestSuiteTreeNode( TestResult result )
     : base(result.Test.TestName.Name)
 {
     this.test = result.Test;
     this.result = result;
     UpdateImageIndex();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TestUnitWithMetadata"/> class.
 /// </summary>
 /// <param name="testRun">The test run.</param>
 /// <param name="test"></param>
 /// <param name="assemblyName">Name of the assembly.</param>
 /// <param name="children">The children.</param>
 public TestUnitWithMetadata(TestRun testRun, ITest test, string assemblyName, List<TestUnitWithMetadata> children = null)
 {
     Children = children ?? new List<TestUnitWithMetadata>();
     Test = new TestUnit(test, testRun, assemblyName);
     Results = new List<TestResult>();
     AttachedData = new TestUnitAttachedData();
 }
 public static ITestResult Failed(
     ITest		test,
     string		message,
     Exception	t)
 {
     return new SimpleTestResult(false, test.Name + ": " + message, t);
 }
Example #23
0
        private static string BuildStackTrace(Exception exception, ITest test, IEnumerable<string> traceMessages)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("SPECIFICATION:");
            if (test.Properties.Contains(TestExtensions.MultilineNameProperty))
            {
                foreach (var line in ((string)test.Properties[TestExtensions.MultilineNameProperty]).Split('\n'))
                    sb.AppendLine("    " + line);
            }

            sb.AppendLine();

            if (traceMessages.Count() > 0)
            {
                foreach (var line in traceMessages)
                    sb.AppendLine(line);

                sb.AppendLine();
            }

            sb.AppendLine(GetStackTrace(exception));

            for (Exception innerException = exception.InnerException; innerException != null; innerException = innerException.InnerException)
            {
                sb.Append(Environment.NewLine);
                sb.Append("--");
                sb.Append(innerException.GetType().Name);
                sb.Append(Environment.NewLine);
                sb.Append(GetStackTrace(innerException));
            }
            return sb.ToString();
        }
Example #24
0
        protected static void RunTest(ITest test)
        {
            int loops = Calibrate(test, TimeSpan.FromMilliseconds(1000));

            var sw = new Stopwatch();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            var c1 = GC.CollectionCount(0);
            var c2 = GC.CollectionCount(1);
            var c3 = GC.CollectionCount(2);

            sw.Start();
            test.DoTest(loops);
            sw.Stop();

            c1 = GC.CollectionCount(0) - c1;
            c2 = GC.CollectionCount(1) - c2;
            c3 = GC.CollectionCount(2) - c3;

            var lps = (int)(loops / (sw.ElapsedMilliseconds / 1000.0));

            Console.WriteLine("{0,-40} {1,20} loops/s, collections {2}/{3}/{4}",
                test.GetType().Name, lps,
                c1, c2, c3);
        }
        private int ProcessTestCases(ITest test, ITestCaseDiscoverySink discoverySink, TestConverter testConverter)
        {
            int cases = 0;

            if (test.IsSuite)
            {
                foreach (ITest child in test.Tests)
                    cases += ProcessTestCases(child, discoverySink,testConverter);
            }
            else
            {
                try
                {
            #if LAUNCHDEBUGGER
            Debugger.Launch();
            #endif
                    TestCase testCase = testConverter.ConvertTestCase(test);

                    discoverySink.SendTestCase(testCase);
                    cases += 1;
                }
                catch (System.Exception ex)
                {
                    testLog.SendErrorMessage("Exception converting " + test.TestName.FullName, ex);
                }
            }

            return cases;
        }
		public void AddCategories( ITest test )
		{
            if (test.Categories != null)
                foreach (string name in test.Categories)
                    if (NUnitFramework.IsValidCategoryName(name))
                        Add(name);
		}
Example #27
0
    //public AlgorithmEvaluator(AlgorithmExecutor executor, ICollection<ITest> tests, IAnswerEvaluator answerEvaluator, TimeSpan timeLimit) : this(tests, answerEvaluator, timeLimit)
    //{
    //    this.executor = executor;
    //}
    //public AlgorithmEvaluator(string algorithmFolder, ICollection<ITest> tests, IAnswerEvaluator answerEvaluator, TimeSpan timeLimit)
    //    : this(new AlgorithmExecutor(algorithmFolder), tests, answerEvaluator, timeLimit)
    //{
    //}
    //public void SetAlgorithm(AlgorithmExecutor newAlg)
    //{
    //    this.executor = newAlg;
    //}
    public int EvaluateWithTest(AlgorithmExecutor algorithm, ITest test, bool allowTimeLimit = false)
    {
        this.logWriter.WriteLine();
        this.logWriter.WriteLine("Evaluating {0} with test {1}", algorithm.AlgorithmOwner, test.Name);

        try
        {
            algorithm.StartAlgorithm();
        }
        catch (Win32Exception)
        {
            this.logWriter.WriteLine("--couldn't start algorithm");
            return 0;
        }

        DateTime start = DateTime.Now;

        string algorithmAnswer = "";
        try
        {
            Task<string> algorithmAnswerTask = Task.Run(() => algorithm.GetAnswerToInput(test.Input));

            bool timeLimitReached = false;
            //Console.WriteLine("press enter");
            //Console.ReadLine();
            System.Threading.Thread.Sleep(timeLimit - TimeSpan.FromMilliseconds(100));
            while (!algorithmAnswerTask.IsCompleted)
            {
                TimeSpan elapsed = DateTime.Now - start;
                if (elapsed > timeLimit)
                {
                    this.logWriter.WriteLine("--time limit reached, killing algorithm");
                    algorithm.KillAlgorithm();
                    timeLimitReached = true;
                    break;
                }
            }

            if (!timeLimitReached || allowTimeLimit)
            {
                this.logWriter.WriteLine("--attempting to retrieve output from algorithm");
                algorithmAnswerTask.Wait();
                algorithmAnswer += algorithmAnswerTask.Result;
            }
            else
            {
                return 0;
            }

            algorithm.KillAlgorithm(); //just in case
        }
        catch (Exception e)
        {
            this.logWriter.WriteLine("--unexpected error while evaluating: {0}", e.Message);
        }

        this.logWriter.Write("--algorithm output:\r\n{0}\r\n", algorithmAnswer);
        return this.evaluator.EvaluateAnswer(algorithmAnswer, test.Input, test.ExpectedOutput);
    }
Example #28
0
		/// <summary>
		/// Checks whether the OrFilter is matched by a test
		/// </summary>
		/// <param name="test">The test to be matched</param>
		/// <returns>True if any of the component filters match, otherwise false</returns>
		public override bool Match( ITest test )
		{
			foreach( TestFilter filter in _filters )
				if ( filter.Match( test ) )
					return true;

			return false;
		}
Example #29
0
 /// <summary>
 /// Causes a test to be skipped if this PlatformAttribute is not satisfied.
 /// </summary>
 /// <param name="test">The test to modify</param>
 public void ApplyToTest(ITest test)
 {
     if (test.RunState != RunState.NotRunnable && !platformHelper.IsPlatformSupported(this))
     {
         test.RunState = RunState.Skipped;
         test.Properties.Add(PropertyNames.SkipReason, platformHelper.Reason);
     }
 }
Example #30
0
		/// <summary>
		/// Check if a test matches the filter
		/// </summary>
		/// <param name="test">The test to match</param>
		/// <returns>True if it matches, false if not</returns>
		public override bool Match( ITest test )
		{
			foreach( TestName testName in testNames )
				if ( test.TestName == testName )
					return true;

			return false;
		}
 public void SetUp()
 {
     traceTestNameAttribute = new TraceTestNameAttribute();
     fakeTest = Substitute.For <ITest>();
     fakeTest.FullName.Returns("Foo");
 }
Example #32
0
        protected override void UpdateTestClass(ITest test, ITypeDefinition typeDefinition)
        {
            var testClass = test as MSTestClass;

            testClass.Update(typeDefinition);
        }
Example #33
0
 private static bool HasChildIndex(ITest test)
 {
     return(test.Properties["childIndex"].Count > 0);
 }
 public TestController(ILogger logger, ITest test)
 {
     this.logger = logger;
     this.test   = test;
 }
Example #35
0
 public static IEnumerable <ITest> GetChildren(this ITest test) => GetChildren(test, true);
Example #36
0
 public Test2(ITest test)
 {
     Test = test;
 }
Example #37
0
 public int callInterface9(ITest itest)
 {
     itest.refProp = new TestClass(3);
     return(itest.refProp.testval);
 }
 protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList <BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
 {
     return(new AspNetTestRunner(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource));
 }
Example #39
0
 /// <summary>
 /// Checks whether the CompositeFilter is matched by a test.
 /// </summary>
 /// <param name="test">The test to be matched</param>
 public abstract override bool Pass(ITest test);
Example #40
0
 /// <summary>
 /// Checks whether the CompositeFilter is matched by a test.
 /// </summary>
 /// <param name="test">The test to be matched</param>
 public abstract override bool Match(ITest test);
Example #41
0
 /// <summary>
 /// Checks whether the CompositeFilter is explicit matched by a test.
 /// </summary>
 /// <param name="test">The test to be matched</param>
 public abstract override bool IsExplicitMatch(ITest test);
Example #42
0
 public void AfterTest([NotNull] ITest test)
 {
 }
Example #43
0
 private static async Task UpdateAcl(ISession <PrivateAuthentication> session, ITest test, List <AclSpec> data)
 {
     await UpdateAcl(data)(session, test);
 }
Example #44
0
 public void AfterTest(ITest test)
 {
     _transactionScope.Dispose();
 }
Example #45
0
        private static void RodarTeste(ITest classeTeste)
        {
            RootTest rootTest = new RootTest(classeTeste);

            rootTest.RunTests();
        }
Example #46
0
 public int callInterface8(ITest itest)
 {
     itest.intProp = 3;
     return(itest.intProp);
 }
 public override void AfterTest(ITest test)
 {
     SharedDatabaseLocator.Cleanup();
 }
Example #48
0
 public int callInterface5(ITest itest)
 {
     return(itest.test5(new TestClass(2), new TestClass(3)));
 }
Example #49
0
 /// <summary>
 /// Match a test against a single value.
 /// </summary>
 public override bool Match(ITest test)
 {
     return(Match(test.FullName));
 }
Example #50
0
 public int callInterface4(ITest itest)
 {
     return(itest.test4(2, 3).testval);
 }
Example #51
0
 public MyJob()
 {
     _test = MvcApplication.Container.Resolve <ITest>();
 }
Example #52
0
 public int callInterface1(ITest itest)
 {
     return(itest.test1(2, 3));
 }
Example #53
0
        int OnTick(ILua lua)
        {
            if (current_test == null)
            {
                if (ListOfTests.Count == 0 && !WasServerQuitTrigered)
                {
                    if (IsEverythingSuccessful)
                    {
                        lua.Log("All tests were completed successfully!");
                        lua.Log("Test run time is " + DateTime.Now.Subtract(tests_start_time).TotalSeconds + " seconds");
                        File.WriteAllText("tests-success.txt", "Success!");

                        lua.Log("Shutting down game...");
                        lua.PushSpecial(SPECIAL_TABLES.SPECIAL_GLOB);
                        lua.GetField(-1, "engine");
                        lua.GetField(-1, "CloseServer");
                        lua.MCall(0, 0);

                        WasServerQuitTrigered = true;
                    }
                    else
                    {
                        lua.Log("There are no more tests to run. Some tests have failed. Check log.", true);
                        lua.Log("Test run time is " + DateTime.Now.Subtract(tests_start_time).TotalSeconds + " seconds");

                        lua.Log("Shutting down game...");
                        lua.PushSpecial(SPECIAL_TABLES.SPECIAL_GLOB);
                        lua.GetField(-1, "engine");
                        lua.GetField(-1, "CloseServer");
                        lua.MCall(0, 0);

                        WasServerQuitTrigered = true;
                    }
                }
                else if (ListOfTests.Count != 0)
                {
                    ITest cur_test_inst = ListOfTests.First();
                    ListOfTests.RemoveAt(0);

                    lua.Log("Starting test " + cur_test_inst.GetType().ToString());

                    Task <bool> cur_test_promise = cur_test_inst.Start(lua, this.lua_extructor, current_load_context);

                    current_test = new Tuple <ITest, Task <bool> >(cur_test_inst, cur_test_promise);
                }
            }
            else
            {
                if (current_test.Item2.IsCompleted)
                {
                    ITest       curr_test_inst    = current_test.Item1;
                    Task <bool> curr_test_promise = current_test.Item2;

                    current_test = null;

                    if (curr_test_promise.IsCompletedSuccessfully)
                    {
                        if (curr_test_promise.Result)
                        {
                            lua.Log("Test " + curr_test_inst.GetType().ToString() + " was completed successfully");
                        }
                        else
                        {
                            lua.Log("FAILED TEST " + curr_test_inst.GetType().ToString() + ". An exception was not thrown", true);
                            this.IsEverythingSuccessful = false;
                        }
                    }
                    else if (curr_test_promise.IsFaulted)
                    {
                        string exception_msg = "";
                        foreach (Exception e in curr_test_promise.Exception.InnerExceptions)
                        {
                            exception_msg += "\n" + e.GetType().ToString() + " - " + e.Message;
                        }
                        lua.Log("FAILED TEST " + curr_test_inst.GetType().ToString() + ". List of exceptions: " + exception_msg, true);
                        this.IsEverythingSuccessful = false;
                    }
                }
            }

            return(0);
        }
 public void AfterTest(ITest test)
 {
 }
Example #55
0
 private static int GetChildIndex(ITest test)
 {
     return((int)test.Properties["childIndex"][0]);
 }
 public void AfterTest(ITest test)
 {
     disposables?.Dispose();
 }
Example #57
0
 public TestRowException(ITest test, IRow row, string msg)
     : base(msg)
 {
     Test = test;
     Row  = row;
 }
 protected abstract void BeforeTest(ITest test, Configuration configuration);
 public void AfterTest(ITest test)
 {
     ContextWriter.WriteLine(ClassDescription);
 }
Example #60
0
 public void BeforeTest(ITest test)
 {
     _transactionScope = new TransactionScope();
 }