• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NUnit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: NUnitExecute

        public void NUnitExecute()
        {
            #region Find NUnit installation
            string nunitPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            nunitPath = Path.Combine(nunitPath, NUnit.DEFAULT_NUNIT_DIRECTORY);

            RegistryKey buildKey = Registry.ClassesRoot.OpenSubKey(@"NUnitTestProject\shell\open\command");
            if (buildKey == null) Assert.Ignore(@"Can't find NUnit installation");

            nunitPath = buildKey.GetValue(null, nunitPath).ToString();
            Regex nunitRegex = new Regex("(.+)nunit-gui\\.exe", RegexOptions.IgnoreCase);
            Match pathMatch = nunitRegex.Match(nunitPath);
            nunitPath = pathMatch.Groups[1].Value.Replace("\"", "");

            #endregion Find NUnit installation

            MockBuild buildEngine = new MockBuild();

            string testDirectory = TaskUtility.makeTestDirectory(buildEngine);

            NUnit task = new NUnit();
            task.BuildEngine = buildEngine;
            task.Assemblies = TaskUtility.StringArrayToItemArray(
                Path.Combine(nunitPath, "nunit.framework.tests.dll"));
            task.WorkingDirectory = testDirectory;
            task.OutputXmlFile = Path.Combine(testDirectory, @"nunit.framework.tests-results.xml");
            Assert.IsTrue(task.Execute(), "Execute Failed");
        }
开发者ID:trippleflux,项目名称:jezatools,代码行数:28,代码来源:NUnitTest.cs


示例2: LoadSettings

		public void LoadSettings(NUnit.Util.ISettings settings)
		{
			this.settings = settings;

			TabInfoCollection info = new TabInfoCollection();
			string tabList = (string)settings.GetSetting( Prefix + "TabList" );

			if ( tabList != null ) 
			{
				string[] tabNames = tabList.Split( new char[] { ',' } );
				foreach( string name in tabNames )
				{
					string prefix = Prefix + name;
					string text = (string)settings.GetSetting(prefix + ".Title");
					if ( text == null )
						break;

					TabInfo tab = new TabInfo( name, text );
					tab.Content = (TextDisplayContent)settings.GetSetting(prefix + ".Content", TextDisplayContent.Empty );
					tab.Enabled = settings.GetSetting( prefix + ".Enabled", true );
					info.Add( tab );
				}
			}

			if ( info.Count > 0 )		
				tabInfo = info;
			else 
				LoadDefaults();
		}
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:29,代码来源:TextDisplayTabSettings.cs


示例3: NUnitAssemblyTest

        /// <summary>
        /// Creates an NUnit assembly-level test.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="runner">The NUnit test runner.</param>
        public NUnitAssemblyTest(IAssemblyInfo assembly, NUnit.Core.TestRunner runner)
            : base(assembly.Name, assembly, runner.Test)
        {
            Kind = TestKinds.Assembly;

            this.runner = runner;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:12,代码来源:NUnitAssemblyTest.cs


示例4: AfterTest

		/// <summary>
		/// Method gets called once at the end of running the tests
		/// </summary>
		public override void AfterTest(NUnit.Framework.TestDetails testDetails)
		{
			if (Environment.OSVersion.Platform != PlatformID.Unix &&
				!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDAGENT_SUBKEY")))
			{
				// End redirection. Otherwise test might fail when we run them multiple
				// times in NUnit.
				RegOverridePredefKey(HKEY_CURRENT_USER, UIntPtr.Zero);
			}
			base.AfterTest(testDetails);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:14,代码来源:RedirectHKCU.cs


示例5: BeforeTest

		/// <summary>
		/// Method gets called once at the very start of running the tests
		/// </summary>
		public override void BeforeTest(NUnit.Framework.TestDetails testDetails)
		{
			base.BeforeTest(testDetails);

			if (Environment.OSVersion.Platform != PlatformID.Unix &&
				!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDAGENT_SUBKEY")))
			{
				UIntPtr hKey;
				RegCreateKey(HKEY_CURRENT_USER, TmpRegistryKey, out hKey);
				RegOverridePredefKey(HKEY_CURRENT_USER, hKey);
				RegCloseKey(hKey);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:16,代码来源:RedirectHKCU.cs


示例6: SuiteFinished

        public void SuiteFinished(NUnit.Core.TestResult result)
        {
            if(result.FullName.Equals(myRootName))
            {
                return;
            }

            JSONClass jsonClass = new JSONClass();
            jsonClass.Add("name", result.Name);
            jsonClass.Add("uuid", myUUID);
            jsonClass.Add("type", "SuiteFinished");

            ConsuloIntegration.SendToConsulo("unityTestState", jsonClass);
        }
开发者ID:consulo,项目名称:UnityEditorConsuloPlugin,代码行数:14,代码来源:NUnitTestListener.cs


示例7: SuiteFinished

 public void SuiteFinished(NUnit.Core.TestResult result)
 {
     if ((result.IsError || result.IsFailure) &&
         (result.FailureSite == FailureSite.SetUp || result.FailureSite == FailureSite.TearDown))
     {
         testLog.SendMessage(
             TestMessageLevel.Error,
             string.Format("{0} failed for test fixture {1}", result.FailureSite, result.FullName));
         if (result.Message != null)
             testLog.SendMessage(TestMessageLevel.Error, result.Message);
         if (result.StackTrace != null)
             testLog.SendMessage(TestMessageLevel.Error, result.StackTrace);
     }
 }
开发者ID:kukubadze,项目名称:nunit-vs-adapter,代码行数:14,代码来源:NUnitEventListener.cs


示例8: SuiteStarted

        public void SuiteStarted(NUnit.Core.TestName testName)
        {
            if(myRootName == null)
            {
                myRootName = testName.FullName;
                return;
            }

            JSONClass jsonClass = new JSONClass();
            jsonClass.Add("uuid", myUUID);
            jsonClass.Add("name", testName.Name);
            jsonClass.Add("type", "SuiteStarted");

            ConsuloIntegration.SendToConsulo("unityTestState", jsonClass);
        }
开发者ID:consulo,项目名称:UnityEditorConsuloPlugin,代码行数:15,代码来源:NUnitTestListener.cs


示例9: WriteActualValueTo

        public override void WriteActualValueTo(NUnit.Framework.Constraints.MessageWriter writer)
        {
            int lines = Math.Min(expectedLines.Length, actualLines.Length);
            for (int i = 0; i < lines; i++)
            {
                string expectedLine = expectedLines[i];
                string actualExLine = actualLines[i];
                if (!(expectedLine.Equals(actualExLine)))
                {
                    writer.WriteActualValue(actualExLine + ", line " + (i + 1).ToString() + Environment.NewLine + expected);
                    return;
                }

            }

            writer.WriteActualValue("actual text is " + actualLines.Length + " lines");
        }
开发者ID:thinkAmi,项目名称:9784774153773_JUnit,代码行数:17,代码来源:MultiLineStringConstraint.cs


示例10: WaitForMessageBox

        /// <summary>
        /// The delegate to handle the message box is installed.
        /// </summary>
        /// <param name="cmd">Contains a NUnit.Extensions.Forms.MessageBoxTester.Command to
        /// insert the desired reaction.</param>
        public void WaitForMessageBox(NUnit.Extensions.Forms.MessageBoxTester.Command cmd)
        {
            lastMessageTitle = "";
            lastMessageText = "";

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);

                System.Console.WriteLine("Title: " + tester.Title);
                System.Console.WriteLine("Message: " + tester.Text);

                lastMessageTitle = tester.Title;
                lastMessageText = tester.Text;

                tester.SendCommand(cmd);
            };
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:23,代码来源:CommonNUnitFormFunctions.cs


示例11: NUnitExecuteWhenToolPathIsDefined

        public void NUnitExecuteWhenToolPathIsDefined(int majorVersion, int minorVersion, int number)
        {
            string nUnitDirName = string.Format("NUnit {0}.{1}.{2}", majorVersion, minorVersion, number);
            string nunitPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), nUnitDirName), "bin");
            if (!Directory.Exists(nunitPath))
            {
                Assert.Inconclusive("{0} - not found", nunitPath);
            }

            MockBuild buildEngine = new MockBuild();
            string testDirectory = TaskUtility.makeTestDirectory(buildEngine);

            NUnit task = new NUnit();
            task.ToolPath = nunitPath;
            task.BuildEngine = buildEngine;
            task.Assemblies = TaskUtility.StringArrayToItemArray(Path.Combine(nunitPath, "nunit.framework.tests.dll"));
            task.WorkingDirectory = testDirectory;
            Assert.IsTrue(task.Execute(), "Execute Failed");
        }
开发者ID:KGuetter,项目名称:msbuildtasks,代码行数:19,代码来源:NUnitTest.cs


示例12: WriteDescriptionTo

        public override void WriteDescriptionTo(NUnit.Framework.Constraints.MessageWriter writer)
        {
            if (expected == null || actualEx == null)
            {
                writer.WriteExpectedValue(expected);
            }
            else
            {
                int lines = Math.Min(expectedLines.Length, actualLines.Length);
                for (int i = 0; i < lines; i++)
                {
                    string expectedLine = expectedLines[i];
                    string actualExLine = actualLines[i];
                    if (!(expectedLine.Equals(actualExLine)))
                    {
                        writer.WriteExpectedValue(expectedLine);
                        return;
                    }
                }

                writer.WriteExpectedValue("expected text is " + expectedLines.Length + " lines");
            }
        }
开发者ID:thinkAmi,项目名称:9784774153773_JUnit,代码行数:23,代码来源:MultiLineStringConstraint.cs


示例13: ParseTestList

		private UnitTestResult[] ParseTestList ( NUnit.Core.Test test, string currentAssemblyPath )
		{
			if (test.IsSuite)
			{
				var tests = new List<UnitTestResult> ();
				foreach (var obj in test.Tests)
				{
					if (obj is TestAssembly && File.Exists ((obj as TestAssembly).TestName.FullName))
						currentAssemblyPath = (obj as TestAssembly).TestName.FullName;

					if (obj is NUnit.Core.Test)
					{
						var results = ParseTestList (obj as NUnit.Core.Test, currentAssemblyPath);
						tests.AddRange (results);
					}
				}
				return tests.ToArray ();
			}
			else
			{
				return new[] { CreateNewTestResult (test as TestMethod, currentAssemblyPath) };
			}
		}
开发者ID:Eji4h,项目名称:GrowingGamesGuidedByTests,代码行数:23,代码来源:NUnitTestEngine.cs


示例14: SuiteFinished

			public void SuiteFinished(NUnit.Core.TestResult result)
			{
			}
开发者ID:eyalzur,项目名称:CodeSamplesPublic,代码行数:3,代码来源:NUnitTestEngine.cs


示例15: RunFinished

 public void RunFinished(NUnit.Core.TestResult result)
 {
 }
开发者ID:kukubadze,项目名称:nunit-vs-adapter,代码行数:3,代码来源:NUnitEventListener.cs


示例16: Run

 public TestResult Run(NUnit.Framework.Internal.Test test)
 {
     TestExecutionContext current = TestExecutionContext.CurrentContext;
     current.WorkDirectory = System.Environment.CurrentDirectory;
     current.Listener = this;
     current.TestObject = test is TestSuite ? null : Reflect.Construct ((test as TestMethod).Method.ReflectedType, null);
     WorkItem wi = test.CreateWorkItem (Filter ?? TestFilter.Empty);
     if (test is TestMethod)
         (test.Parent as TestSuite).GetOneTimeSetUpCommand ().Execute (current);
     wi.Execute (current);
     if (test is TestMethod)
         (test.Parent as TestSuite).GetOneTimeTearDownCommand ().Execute (current);
     return wi.Result;
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:14,代码来源:AndroidRunner.cs


示例17: Write

		public void Write( NUnit.Core.TestOutput output )
		{
			Write( output.Text );
		}
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:4,代码来源:TextBoxDisplay.cs


示例18: UpdateTestResults

		private void UpdateTestResults(NUnit.Core.TestResult result)
		{
			ToUnitTestResult(result);
		}
开发者ID:eyalzur,项目名称:CodeSamplesPublic,代码行数:4,代码来源:NUnitTestEngine.cs


示例19: WriteActualValueTo

 public override void WriteActualValueTo(NUnit.Framework.Constraints.MessageWriter writer)
 {
     writer.WriteActualValue(actualValue);
 }
开发者ID:thinkAmi,项目名称:9784774153773_JUnit,代码行数:4,代码来源:EmployeeConstraint.cs


示例20: events_TestUnloaded

		private void events_TestUnloaded(object sender, NUnit.Util.TestEventArgs args)
		{
			availableCategories.Clear();
			availableList.Items.Clear();
			selectedList.Items.Clear();
			excludeCheckbox.Checked = false;
			excludeCheckbox.Enabled = false;
			treeMenu.Visible = false;
		}
开发者ID:Buildstarted,项目名称:ContinuousTests,代码行数:9,代码来源:TestTree.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NUnit.Framework类代码示例发布时间:2022-05-24
下一篇:
C# NTree类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap