本文整理汇总了C#中TestResult类的典型用法代码示例。如果您正苦于以下问题:C# TestResult类的具体用法?C# TestResult怎么用?C# TestResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestResult类属于命名空间,在下文中一共展示了TestResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTitle
private string BuildTitle(TestResult successful)
{
var sb = new StringBuilder();
switch (successful)
{
default:
case TestResult.Inconclusive:
sb.AppendFormat("{0}", "Inconclusive");
break;
case TestResult.Passed:
sb.AppendFormat("{0}", "Successful");
break;
case TestResult.Failed:
sb.AppendFormat("{0}", "Failed");
break;
}
if (!string.IsNullOrEmpty(this.configuration.SystemUnderTestName) &&
!string.IsNullOrEmpty(this.configuration.SystemUnderTestVersion))
{
sb.AppendFormat(" with {0} version {1}", this.configuration.SystemUnderTestName, this.configuration.SystemUnderTestVersion);
}
else if (!string.IsNullOrEmpty(this.configuration.SystemUnderTestName))
{
sb.AppendFormat(" with {0}", this.configuration.SystemUnderTestName);
}
else if (!string.IsNullOrEmpty(this.configuration.SystemUnderTestVersion))
{
sb.AppendFormat(" with version {0}", this.configuration.SystemUnderTestVersion);
}
return sb.ToString();
}
示例2: RunTest
private static TestResult RunTest(object instance, MethodBase method)
{
var result = new TestResult { Name = method.Name };
var sw = new Stopwatch();
sw.Start();
try
{
method.Invoke(instance, null);
result.WasSuccessful = true;
}
catch (Exception ex)
{
result.WasSuccessful = false;
result.Message = ex.ToString();
}
finally
{
sw.Stop();
result.Duration = sw.ElapsedMilliseconds;
}
return result;
}
示例3: Init
public void Init()
{
base.InitBase();
project = new MockCSharpProject();
MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun();
context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject);
classToTest = MockClass.CreateMockClassWithoutAnyAttributes();
classToTest.SetDotNetName("MyTestClass");
treeView = new MockTestTreeView();
treeView.SelectedProject = project;
treeView.SelectedClass = classToTest;
runTestCommand.Owner = treeView;
runTestCommand.Run();
buildProject.FireBuildCompleteEvent();
TestResult result = new TestResult("MyTestClass");
result.ResultType = TestResultType.Success;
context.MockTestResultsMonitor.FireTestFinishedEvent(result);
runTestCommand.CallTestsCompleted();
}
示例4: TestPacketTimeouts
public void TestPacketTimeouts()
{
try
{
BrainCloudClient.Get().Initialize(_serverUrl + "unitTestFail", _secret, _appId, _version);
BrainCloudClient.Get ().EnableLogging(true);
BrainCloudClient.Get ().SetPacketTimeouts(new List<int> {3, 3, 3});
DateTime timeStart = DateTime.Now;
TestResult tr = new TestResult();
tr.SetTimeToWaitSecs(120);
BrainCloudClient.Get().AuthenticationService.AuthenticateUniversal("abc", "abc", true, tr.ApiSuccess, tr.ApiError);
tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);
DateTime timeEnd = DateTime.Now;
TimeSpan delta = timeEnd.Subtract(timeStart);
if (delta < TimeSpan.FromSeconds (8) && delta > TimeSpan.FromSeconds(15))
{
Console.WriteLine("Failed timing check - took " + delta.TotalSeconds + " seconds");
Assert.Fail ();
}
}
finally
{
// reset to defaults
BrainCloudClient.Get ().SetPacketTimeoutsToDefault();
}
}
示例5: TestFinished
public void TestFinished(TestResult result)
{
_testRunInfo.Running = false;
_testRunInfo.Passed = result.IsSuccess;
_testRunInfo.TestResult = result;
RunOnUiThread(() => _detailsView.Description = DefaultDescription);
}
示例6: SubmitResult
public static void SubmitResult(Uri testVaultServer, string session, string project, string buildname, string testgroup, string testname, TestOutcome outcome, bool personal)
{
try
{
using ( var client = new WebClient() ){
client.BaseAddress = testVaultServer.ToString();
client.CachePolicy = new System.Net.Cache.RequestCachePolicy( System.Net.Cache.RequestCacheLevel.NoCacheNoStore );
client.Headers.Add("Content-Type", "text/xml");
var result = new TestResult()
{
Group = new TestGroup() { Name = testgroup, Project = new TestProject() { Project = project } },
Name = testname,
Outcome = outcome,
TestSession = session,
IsPersonal = personal,
BuildID = buildname,
};
var xc = new XmlSerializer(result.GetType());
var io = new System.IO.MemoryStream();
xc.Serialize( io, result );
client.UploadData( testVaultServer.ToString(), io.ToArray() );
}
} catch ( Exception e )
{
Console.Error.WriteLine( e );
}
}
示例7: TestStarted
public void TestStarted (TestResult test)
{
foreach (var unitTestRunnerCallback in callbackList)
{
unitTestRunnerCallback.TestStarted(test);
}
}
示例8: EndTest
public void EndTest(string testId, TestResult testResult)
{
foreach (ILogger logger in Loggers)
{
logger.EndTest(testId, testResult);
}
}
示例9: AddTestResult
public void AddTestResult(TestResult result)
{
if (result.stateFlag.Equals(TestResultObject.STATE_FLAG_SEVERE)) {
isSevere = true;
}
testResults.Add(result);
}
示例10: PrintSingleTest
public static void PrintSingleTest()
{
var directories = GetBuildDirectories();
var tests = new List<TestResult>();
foreach (var dir in directories)
{
var files = Directory.GetFiles(dir, "junitResult.xml");
if (files.Any())
{
var fileName = files[0];
var iterator = GetTestCasesWithErrors("UserAcceptanceTests.Features.ProductFeature","RefreshOnProductAfterAddingCommentShouldNOTResultInErrorBugFix",fileName);
while (iterator.MoveNext())
{
var failingTest = GetFailingTestName(iterator);
var testResult = new TestResult {BuildName = GetBuildName(dir),TestName = failingTest};
tests.Add(testResult);
}
}
}
foreach (var failingTest in tests.ToList().OrderBy(x=>x.BuildName).Reverse())
{
Console.WriteLine(failingTest);
}
}
示例11: EWMTestMapping
public void EWMTestMapping()
{
var testResult = new TestResult()
{
TestID = 1,
ProdName = "Thomson Reuters Eikon for Wealth Management",
ProdVers = "1",
TestCases = new List<TestCase>()
};
testResult.TestCases.Add(new TestCase()
{
ID = "1",
Title = "Browser Version:"
});
testResult.TestCases.Add(new TestCase()
{
ID = "2",
Title = "Operating System:"
});
var list = new List<TestResult> {testResult};
DataMapper.MapStatCodeEWM(testResult);
Assert.IsNotNull(testResult);
}
示例12: AddTestResult
public void AddTestResult(ContentFile contentFile, TestResult testResult)
{
var checksum = contentFile.Checksum;
var storagePath = Path.Combine(_storagePath, checksum);
try
{
if (!FileUtil.EnsureDirectory(storagePath))
{
return;
}
Write(checksum, StorageKind.ExitCode, testResult.ExitCode.ToString());
Write(checksum, StorageKind.AssemblyPath, testResult.AssemblyPath);
Write(checksum, StorageKind.StandardOutput, testResult.StandardOutput);
Write(checksum, StorageKind.ErrorOutput, testResult.ErrorOutput);
Write(checksum, StorageKind.CommandLine, testResult.CommandLine);
Write(checksum, StorageKind.Content, contentFile.Content);
if (!string.IsNullOrEmpty(testResult.ResultsFilePath))
{
File.Copy(testResult.ResultsFilePath, GetStoragePath(checksum, StorageKind.ResultsFile));
}
}
catch (Exception e)
{
// I/O errors are expected and okay here.
Logger.Log($"Failed to log {checksum} {e.Message}");
FileUtil.DeleteDirectory(storagePath);
}
}
示例13: ProcessRecordThrowsExpectedExceptionSuccess
public void ProcessRecordThrowsExpectedExceptionSuccess()
{
// Arrange.
var test = new Test(
"t",
ScriptBlock.Create(string.Empty),
typeof(ArgumentNullException)
);
var testResult = new TestResult("tr", true);
var runtime = MockRepository.GenerateStrictMock<ICommandRuntime>();
runtime.Expect(r => r.WriteObject(testResult));
var cmdlet = MockRepository
.GeneratePartialMock<TestableInvokeTestCmdlet>();
cmdlet.Test = new[] { test };
cmdlet.CommandRuntime = runtime;
cmdlet
.Expect(c => c.InvokeScriptBlock(test.TestScript))
.Throw(new Exception("", new ArgumentNullException()));
cmdlet
.Expect(c => c.CreateTestResult(test.Name, true))
.Return(testResult);
// Act.
cmdlet.DoProcessRecord();
// Assert.
cmdlet.VerifyAllExpectations();
runtime.VerifyAllExpectations();
}
示例14: Visit
private void Visit(TestResult result)
{
if (result.Test is TestSuite)
{
if (result.Results != null)
foreach (TestResult r in result.Results)
Visit(r);
return;
}
// We only count non-suites
testCount++;
switch (result.ResultState)
{
case ResultState.NotRun:
notRunCount++;
break;
case ResultState.Error:
errorCount++;
break;
case ResultState.Failure:
failureCount++;
break;
default:
break;
}
}
示例15: GenerateSpecificationResult
private static SpecificationResult GenerateSpecificationResult(IAmSpecification instance)
{
instance.Setup();
var specificationResult = new SpecificationResult()
{
Given = instance.GetGiven().ToString(),
When = instance.When().ToString(),
Results = new List<TestResult>()
};
var tests =
instance.GetType().GetMethods().Where(
y => y.GetCustomAttribute<TestAttribute>() != null);
foreach (var test in tests)
{
var testResult = new TestResult() { Description = test.Name.Replace("_", " "), Passed = true };
try
{
test.Invoke(instance, null);
}
catch (Exception)
{
testResult.Passed = false;
}
specificationResult.Results.Add(testResult);
}
return specificationResult;
}