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


C# NUnit类代码示例

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


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


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