/// <summary> /// Merges the specified other. /// </summary> /// <param name="source"> </param> /// <param name="target"> </param> public void Merge(TestResult source, TestResult target) { var mergedType = GetType(target); var otherType = GetType(source); if (mergedType == TestType.Project && otherType == TestType.Project) { if (string.IsNullOrEmpty(target.FullName) && !string.IsNullOrEmpty(source.FullName)) { target.Test.TestName.FullName = source.FullName; target.Test.TestName.Name = source.Name; } } if (mergedType != otherType) throw new NotSupportedException("Only merging of results with same test type are supported"); if (!target.IsSuccess && source.IsSuccess) { target.Success(source.Message); target.SetAgentName(source.GetAgentName()); } MergeChildren(source, target); }
public TestResult CreateTestResult(TestType type, string fullName, ResultState state = ResultState.Success, Func<IEnumerable<TestResult>> children = null, string stackTrace = null, string description = null, IList categories = null, string agentName = null) { description = description ?? RandomValuesGenerator.GetRandomValue<string>(); agentName = agentName ?? RandomValuesGenerator.GetRandomValue<string>(); var splitted = (fullName ?? string.Empty).Split(new[]{'.'}, StringSplitOptions.RemoveEmptyEntries); var childResults = children != null ? children() : new TestResult[0]; var testResult = new TestResult(new TestInfoWrapper { TestName = new TestName { FullName = fullName, Name = splitted.Length > 0 ? splitted[splitted.Length - 1] : string.Empty }, Categories = categories, IsSuite = type != TestType.TestMethod, TestCount = type == TestType.TestMethod ? 1 : RandomValuesGenerator.GetRandomValue<int>(), TestType = type.ToString() }) { AssertCount = 1, Time = RandomValuesGenerator.GetRandomValue<double>() }; if (state != ResultState.Success) testResult.SetResult(state, description, stackTrace); else testResult.Success(description); testResult.SetAgentName(agentName); foreach (var childResult in childResults) { testResult.AddResult(childResult); } return testResult; }