當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。