当前位置: 首页>>代码示例>>C#>>正文


C# Internal.TestExecutionContext类代码示例

本文整理汇总了C#中NUnit.Framework.Internal.TestExecutionContext的典型用法代码示例。如果您正苦于以下问题:C# TestExecutionContext类的具体用法?C# TestExecutionContext怎么用?C# TestExecutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestExecutionContext类属于NUnit.Framework.Internal命名空间,在下文中一共展示了TestExecutionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

            public override TestResult Execute(TestExecutionContext context)
            {
                string setCulture = (string)Test.Properties.Get(PropertyNames.SetCulture);
                if (setCulture != null)
                    context.CurrentCulture = new System.Globalization.CultureInfo(setCulture);

                return innerCommand.Execute(context);
            }
开发者ID:ChadBurggraf,项目名称:NUnitLite,代码行数:8,代码来源:SetCultureAttribute.cs

示例2: Initialize

		public void Initialize()
		{
            setupContext = new TestExecutionContext(TestExecutionContext.CurrentContext);
#if !NETCF
            currentCulture = CultureInfo.CurrentCulture;
            currentUICulture = CultureInfo.CurrentUICulture;
			currentDirectory = Environment.CurrentDirectory;
            currentPrincipal = Thread.CurrentPrincipal;
#endif
		}
开发者ID:ChadBurggraf,项目名称:NUnitLite,代码行数:10,代码来源:TestExecutionContextTests.cs

示例3: RunTestFixture

        public static TestResult RunTestFixture(Type type)
        {
            TestSuite suite = MakeFixture(type);
            
            TestExecutionContext context = new TestExecutionContext();
            context.TestObject = null;

            CompositeWorkItem work = new CompositeWorkItem(suite, TestFilter.Empty);
            return ExecuteAndWaitForResult(work, context);
        }
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:10,代码来源:TestBuilder.cs

示例4: Initialize

        public void Initialize()
        {
            setupContext = new TestExecutionContext(TestExecutionContext.CurrentContext);
#if !NETCF && !PORTABLE
            originalCulture = CultureInfo.CurrentCulture;
            originalUICulture = CultureInfo.CurrentUICulture;
#endif

#if !NETCF && !SILVERLIGHT && !PORTABLE
            originalDirectory = Environment.CurrentDirectory;
            originalPrincipal = Thread.CurrentPrincipal;
#endif
        }
开发者ID:elv1s42,项目名称:nunit,代码行数:13,代码来源:TestExecutionContextTests.cs

示例5: Execute

			public override TestResult Execute(TestExecutionContext context)
			{
				Type      caughtType = null;
				Exception exception = null;

				try
				{
					innerCommand.Execute(context);
				}
				catch (Exception ex)
				{
					exception = ex;

					if (exception is NUnitException)
						exception = ex.InnerException;

					caughtType = exception.GetType();
				}

				if (caughtType == _expectedType)
				{
					if (_expectedMessage == null || _expectedMessage == exception.Message)
						context.CurrentResult.SetResult(ResultState.Success);
					else
						context.CurrentResult.SetResult(ResultState.Failure,
							"Expected {0} but got {1}".Args(_expectedMessage, exception.Message));

				}
				else if (caughtType != null)
				{
					context.CurrentResult.SetResult(ResultState.Failure,
						"Expected {0} but got {1}".Args(_expectedType.Name, caughtType.Name));
				}
				else
				{
					context.CurrentResult.SetResult(ResultState.Failure,
						"Expected {0} but no exception was thrown".Args(_expectedType.Name));
				}

				return context.CurrentResult;
			}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:41,代码来源:ExpectedExceptionAttribute.cs

示例6: TestExecutionContext

        /// <summary>
        /// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
        /// </summary>
        /// <param name="other">An existing instance of TestExecutionContext.</param>
		public TestExecutionContext( TestExecutionContext other )
		{
			this.prior = other;

            this.currentTest = other.currentTest;
            this.currentResult = other.currentResult;
            this.testObject = other.testObject;
			this.workDirectory = other.workDirectory;
            this.listener = other.listener;
            this.stopOnError = other.stopOnError;
            this.testCaseTimeout = other.testCaseTimeout;

#if !NETCF
            this.currentCulture = CultureInfo.CurrentCulture;
            this.currentUICulture = CultureInfo.CurrentUICulture;
#endif

#if !NETCF && !SILVERLIGHT
			this.outWriter = other.outWriter;
			this.errorWriter = other.errorWriter;
            this.traceWriter = other.traceWriter;
            this.tracing = other.tracing;
#endif

#if !NUNITLITE
			this.logging = other.logging;
			this.currentDirectory = Environment.CurrentDirectory;
            this.logCapture = other.logCapture;
            this.currentPrincipal = Thread.CurrentPrincipal;
#endif
        }
开发者ID:alexanderkyte,项目名称:NUnitLite,代码行数:35,代码来源:TestExecutionContext.cs

示例7: InitializeTestEngine

		/// <summary>
		///		Initializes the underlying test engine.
		/// </summary>
		private static void InitializeTestEngine()
		{
			TestExecutionContext context = new TestExecutionContext();
			context.WorkDirectory = Environment.CurrentDirectory;
			CallContext.SetData( "NUnit.Framework.TestContext", context );
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:9,代码来源:UnitTestDriver.cs

示例8: TestExecutionContext

        /// <summary>
        /// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
        /// </summary>
        /// <param name="other">An existing instance of TestExecutionContext.</param>
        public TestExecutionContext(TestExecutionContext other)
        {
            _priorContext = other;

            this.CurrentTest = other.CurrentTest;
            this.CurrentResult = other.CurrentResult;
            this.TestObject = other.TestObject;
            this.WorkDirectory = other.WorkDirectory;
            _listener = other._listener;
            this.StopOnError = other.StopOnError;
            this.TestCaseTimeout = other.TestCaseTimeout;
            this.UpstreamActions = new List<ITestAction>(other.UpstreamActions);

            _currentCulture = CultureInfo.CurrentCulture;
            _currentUICulture = CultureInfo.CurrentUICulture;

#if !NETCF && !SILVERLIGHT && !PORTABLE
            _currentPrincipal = other.CurrentPrincipal;
#endif

            this.Dispatcher = other.Dispatcher;
            this.ParallelScope = other.ParallelScope;
        }
开发者ID:JohanLarsson,项目名称:nunit,代码行数:27,代码来源:TestExecutionContext.cs

示例9: GetWorkItem

 public static FakeWorkItem GetWorkItem(object obj, string name, TestExecutionContext context)
 {
     return GetWorkItem(obj.GetType(), name, context);
 }
开发者ID:alfeg,项目名称:nunit,代码行数:4,代码来源:Fakes.cs

示例10: Save

 /// <summary>
 /// Saves the old context and makes a fresh one 
 /// current without changing any settings.
 /// </summary>
 public static void Save()
 {
     TestExecutionContext.current = new TestExecutionContext(current);
 }
开发者ID:ChadBurggraf,项目名称:NUnitLite,代码行数:8,代码来源:TestExecutionContext.cs

示例11: SetUp

 public void SetUp()
 {
     _context = new TestExecutionContext();
 }
开发者ID:elv1s42,项目名称:nunit,代码行数:4,代码来源:ApplyToContextTests.cs

示例12: TestContext

 /// <summary>
 /// Construct a TestContext for an ExecutionContext
 /// </summary>
 /// <param name="ec">The ExecutionContext to adapt</param>
 public TestContext(TestExecutionContext ec)
 {
     this.ec = ec;
 }
开发者ID:haf,项目名称:nunit-framework,代码行数:8,代码来源:TestContext.cs

示例13: RunTest

        // This method can't currently be used. It would be more efficient
        // to run test cases using the command directly, but that would
        // cause errors in tests that have a timeout or that require a
        // separate thread or a specific apartment. Those features are
        // handled at the level of the WorkItem in the current build.
        // Therefore, we run all tests, both test cases and fixtures,
        // by creating a WorkItem and executing it. See the RunTest
        // method below.

        //public static ITestResult RunTestMethod(TestMethod testMethod, object fixture)
        //{
        //    TestExecutionContext context = new TestExecutionContext();
        //    context.CurrentTest = testMethod;
        //    context.CurrentResult = testMethod.MakeTestResult();
        //    context.TestObject = fixture;

        //    TestCommand command = testMethod.MakeTestCommand();

        //    return command.Execute(context);
        //}

        //public static ITestResult RunTest(Test test)
        //{
        //    return RunTest(test, null);
        //}

        public static ITestResult RunTest(Test test, object testObject)
        {
            TestExecutionContext context = new TestExecutionContext();
            context.TestObject = testObject;

            WorkItem work = WorkItem.CreateWorkItem(test, TestFilter.Empty);
            work.InitializeContext(context);
            work.Execute();

            // TODO: Replace with an event - but not while method is static
            while (work.State != WorkItemState.Complete)
            {
#if PORTABLE
                System.Threading.Tasks.Task.Delay(1);
#else
                Thread.Sleep(1);
#endif
            }

            return work.Result;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:47,代码来源:TestBuilder.cs

示例14: ExecutionStatusIsPromulgatedAcrossBranches

        public void ExecutionStatusIsPromulgatedAcrossBranches()
        {
            var topContext = new TestExecutionContext();
            var leftContext = new TestExecutionContext(new TestExecutionContext(new TestExecutionContext(topContext)));
            var rightContext = new TestExecutionContext(new TestExecutionContext(new TestExecutionContext(topContext)));

            leftContext.ExecutionStatus = TestExecutionStatus.StopRequested;

            Assert.That(rightContext.ExecutionStatus, Is.EqualTo(TestExecutionStatus.StopRequested));
        }
开发者ID:elv1s42,项目名称:nunit,代码行数:10,代码来源:TestExecutionContextTests.cs

示例15: OneTimeSetUp

 public void OneTimeSetUp()
 {
     fixtureContext = TestExecutionContext.CurrentContext;
 }
开发者ID:elv1s42,项目名称:nunit,代码行数:4,代码来源:TestExecutionContextTests.cs


注:本文中的NUnit.Framework.Internal.TestExecutionContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。