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


C# IServer.UpdateClientStatus方法代码示例

本文整理汇总了C#中IServer.UpdateClientStatus方法的典型用法代码示例。如果您正苦于以下问题:C# IServer.UpdateClientStatus方法的具体用法?C# IServer.UpdateClientStatus怎么用?C# IServer.UpdateClientStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServer的用法示例。


在下文中一共展示了IServer.UpdateClientStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

		/// <summary>
		/// Starts the specified server.
		/// </summary>
		/// <param name="server">The server.</param>
		public void Start(IServer server)
		{
			RequiresNotNull(server);
			var instructions = new BuildInstructions(Guid.Empty, string.Empty, string.Empty);
			try
			{
				instructions = GetBuildInstructions(server);
				BuildProject(server, instructions);
				ExecuteNUnitTestRunner(server, instructions);
			}
			catch (FileNotFoundException e)
			{
				log.Log(LogSeverity.Error,  $"The file was not found: {e.FileName}");
				var status = new ClientInformation(Environment.MachineName, instructions.Session, BuildStatus.Failed,
					new TestResult[0]);
				server.UpdateClientStatus(status);
			}
			catch (Win32Exception e)
			{
				log.Log(LogSeverity.Error, $"Error launching the build process: {e.Message}");
				var status = new ClientInformation(Environment.MachineName, instructions.Session, BuildStatus.Failed,
					new TestResult[0]);
				server.UpdateClientStatus(status);
			}
			catch (ApplicationException e)
			{
				log.Log(LogSeverity.Error, $"Error building the project: {e.Message}");
				var status = new ClientInformation(Environment.MachineName, instructions.Session, BuildStatus.Failed,
					new TestResult[0]);
				server.UpdateClientStatus(status);
			}
		}
开发者ID:jairov4,项目名称:Yorkfield,代码行数:36,代码来源:MainClient.cs

示例2: GetBuildInstructions

		private BuildInstructions GetBuildInstructions(IServer server)
		{
			log.Log(LogSeverity.Information, "Getting build instructions");
			var instructions = server.GetBuildInstructions(Environment.MachineName);
			log.Log(LogSeverity.Information, $"Building session {instructions.Session}");
			var status = new ClientInformation(Environment.MachineName, instructions.Session, BuildStatus.InProgress,
				new TestResult[0]);
			server.UpdateClientStatus(status);
			return instructions;
		}
开发者ID:jairov4,项目名称:Yorkfield,代码行数:10,代码来源:MainClient.cs

示例3: ExecuteNUnitTestRunner

		private void ExecuteNUnitTestRunner(IServer server, BuildInstructions instructions)
		{
			log.Log(LogSeverity.Information, "Executing NUnit Test Runner");
			XmlNode result2;
			using (var r = new TestEngine())
			{
				r.Initialize();
				var pkg = new TestPackage(instructions.TargetUnitTestingAssembly);
				using (var runner = r.GetRunner(pkg))
				{
					var filter = TestFilter.Empty;
					var tests = runner.CountTestCases(filter);
					log.Log(LogSeverity.Information, $"Found {tests} tests");
					result2 = runner.Run(null, filter);
				}
			}
			
			Func<string, TestStatus> parse = x =>
			{
				if(x == "Passed") return TestStatus.Passed;
				return TestStatus.Failed;
			};

			ClientInformation status;
			try
			{
				var root = XDocument.Parse(result2.OuterXml);
				var testResults =
					from el in root.Descendants("test-case")
					select new TestResult(el.Attribute("name").Value, parse(el.Attribute("result").Value));
				status = new ClientInformation(Environment.MachineName, instructions.Session, BuildStatus.Successful, testResults.ToArray());
			}
			catch (Exception e)
			{
				var msg = "Error parsing test result XML document, check version of NUnit";
				log.Log(LogSeverity.Error, msg);
				throw new ApplicationException(msg, e);
			}
			
			server.UpdateClientStatus(status);
			log.Log(LogSeverity.Information, "Test fixtures execution complete");
		}
开发者ID:jairov4,项目名称:Yorkfield,代码行数:42,代码来源:MainClient.cs

示例4: BuildProject

		private void BuildProject(IServer server, BuildInstructions instructions)
		{
			log.Log(LogSeverity.Information, "Building project");
			var startOptions = new ProcessStartInfo(instructions.BuildCommand);
			startOptions.UseShellExecute = false;
			var process = Process.Start(startOptions);
			ClientInformation status;
			if (!process.WaitForExit(TimeOutMilliseconds))
			{
				status = new ClientInformation(Environment.MachineName, instructions.Session, BuildStatus.Failed, new TestResult[0]);
				server.UpdateClientStatus(status);
				log.Log(LogSeverity.Warning, $"Build project is timed out, {process.ExitTime}");
				throw new TimeoutException();
			}

			var result = process.ExitCode == 0 ? BuildStatus.InProgress : BuildStatus.Failed;
			status = new ClientInformation(Environment.MachineName, instructions.Session, result, new TestResult[0]);
			server.UpdateClientStatus(status);
			if (result == BuildStatus.Failed)
			{
				log.Log(LogSeverity.Error, $"Build project failed: executing {instructions.BuildCommand} - Exit code {process.ExitCode}");
				throw new ApplicationException();
			}
		}
开发者ID:jairov4,项目名称:Yorkfield,代码行数:24,代码来源:MainClient.cs


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