本文整理汇总了C#中ResultState类的典型用法代码示例。如果您正苦于以下问题:C# ResultState类的具体用法?C# ResultState怎么用?C# ResultState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResultState类属于命名空间,在下文中一共展示了ResultState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenTestCaseCompletes_NodeShowsProperResult
public void WhenTestCaseCompletes_NodeShowsProperResult(ResultState resultState, int expectedIndex)
{
_model.IsPackageLoaded.Returns(true);
_model.HasTests.Returns(true);
_view.DisplayFormat.SelectedItem.Returns("NUNIT_TREE");
var result = resultState.Status.ToString();
var label = resultState.Label;
var doc = new XmlDocument();
if (string.IsNullOrEmpty(label))
doc.LoadXml(string.Format("<test-run id='1'><test-case id='123' result='{0}'/></test-run>", result));
else
doc.LoadXml(string.Format("<test-run id='1'><test-case id='123' result='{0}' label='{1}'/></test-run>", result, label));
var testNode = new TestNode(doc.FirstChild);
_model.Tests.Returns(testNode);
//var treeNode = _adapter.MakeTreeNode(result);
//_adapter.NodeIndex[suiteResult.Id] = treeNode;
_model.TestLoaded += Raise.Event<TestEventHandler>(new TestEventArgs(TestAction.TestLoaded, testNode));
_model.TestFinished += Raise.Event<TestEventHandler>(new TestEventArgs(TestAction.TestFinished, testNode.Children[0]));
_view.Tree.Received().SetImageIndex(Arg.Any<TreeNode>(), expectedIndex);
}
示例2: IsRunnable
public static void IsRunnable(Type type, string name, ResultState resultState)
{
Test test = TestBuilder.MakeTestCase(type, name);
Assert.That(test.RunState, Is.EqualTo(RunState.Runnable));
TestResult result = test.Run(NullListener.NULL, TestFilter.Empty);
if (result.HasResults)
result = (TestResult)result.Results[0];
Assert.That(result.ResultState, Is.EqualTo(resultState));
}
示例3: RunTests
public void RunTests(MethodInfo testMethod, ResultState resultState, int assertionCount)
{
var method = _builder.BuildFrom(testMethod);
var result = method.Run(new NullListener(), TestFilter.Empty);
Assert.That(result.Executed, Is.True, "Was not executed");
Assert.That(result.ResultState, Is.EqualTo(resultState), "Wrong result state");
Assert.That(result.AssertCount, Is.EqualTo(assertionCount), "Wrong assertion count");
}
示例4: WhenResultIsSet_IndexReflectsResultState
public void WhenResultIsSet_IndexReflectsResultState(ResultState resultState, int expectedIndex)
{
TestSuiteTreeNode node = new TestSuiteTreeNode(new TestInfo(testCase));
TestResult result = new TestResult(testCase);
result.SetResult(resultState, null, null);
node.Result = result;
Assert.AreEqual(expectedIndex, node.ImageIndex);
Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
Assert.AreEqual(resultState.ToString(), node.StatusText);
}
示例5: VerifyResultState
void VerifyResultState(ResultState expectedState, bool executed, bool success, bool failure, bool error, string message )
{
Assert.That( result.ResultState , Is.EqualTo( expectedState ) );
Assert.That( result.Executed, Is.EqualTo( executed ) );
Assert.That( result.IsSuccess, Is.EqualTo( success ) );
Assert.That( result.IsFailure, Is.EqualTo( failure ) );
Assert.That( result.IsError, Is.EqualTo( error ) );
if ( error )
Assert.That(result.Message, Is.EqualTo("System.Exception : " + message));
else
Assert.That(result.Message, Is.EqualTo(message));
}
示例6: RunnerTest
public void RunnerTest(string commandLineArguments, ResultState expectedResultValidate, ResultState expectedResultRun, ParserNotation notation)
{
var configuration = new CommandConfiguration();
configuration.CommandAssemblies.Add(Assembly.GetExecutingAssembly());
var runner = new CommandRunner(new CommandParser(notation), new CommandLookup(configuration));
var result1 = runner.Validate(commandLineArguments);
var result2 = runner.Run(commandLineArguments);
// Assert
Assert.NotNull(result1);
Assert.NotNull(result2);
Assert.True(result1.State == expectedResultValidate);
Assert.True(result2.State == expectedResultRun);
Assert.NotNull(result1.CommandInfo);
}
示例7: GetTestResultMessageForResultState
string GetTestResultMessageForResultState(TestResult testResult, ResultState state, string heading)
{
var messageBuilder = new StringBuilder();
for (var i = 0; i < testResult.Results.Count; i++)
{
var result = (TestResult) testResult.Results[i];
if (result.ResultState == state)
{
messageBuilder.AppendLine(string.Format("{0} for specification {1}", heading, i + 1));
messageBuilder.AppendLine(result.Message);
}
}
return messageBuilder.ToString();
}
示例8: ImageResult
private Image ImageResult(ResultState resState)
{
Image image = new Image();
if (resState.Equals(ResultState.Success))
{
image.ImageUrl = "~/img/passed.png";
}
else if (resState.Equals(ResultState.Ignored))
{
image.ImageUrl = "~/img/Ignored.png";
}
else
{
image.ImageUrl = "~/img/failed.png";
}
return image;
}
示例9: CreateTestResult
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;
}
示例10: Process
public override void Process()
{
try
{
Start = String.IsNullOrEmpty(Request["start"]) ? 0 : Convert.ToInt32(Request["start"]);
Size = String.IsNullOrEmpty(Request["size"]) ? Config.GetInt("imageManagerListSize") : Convert.ToInt32(Request["size"]);
}
catch (FormatException)
{
State = ResultState.InvalidParam;
WriteResult();
return;
}
var buildingList = new List<String>();
try
{
var localPath = Server.MapPath(PathToList);
var allFiles = Directory.GetFiles(localPath, "*", SearchOption.AllDirectories)
.Where(x => SearchExtensions.Contains(Path.GetExtension(x).ToLower()))
.Select(x => PathToList + x.Substring(localPath.Length).Replace("\\", "/"));
var currentUserName = HttpContext.Current.User.Identity.Name;
//只显示该用户自己的文件
var userFiles = allFiles.Where(file => file.Contains(currentUserName)).ToList();
buildingList.AddRange(userFiles);
Total = buildingList.Count;
FileList = buildingList.OrderBy(x => x).Skip(Start).Take(Size).ToArray();
}
catch (UnauthorizedAccessException)
{
State = ResultState.AuthorizError;
}
catch (DirectoryNotFoundException)
{
State = ResultState.PathNotFound;
}
catch (IOException)
{
State = ResultState.IOError;
}
finally
{
WriteResult();
}
}
示例11: UpdateStatus
private void UpdateStatus(ResultState result)
{
// Status can only get worse during a run, so we can avoid
// unnecessary calls to Invoke by checking current status.
var currentStatus = _progressBar.Status;
if (currentStatus != TestProgressBarStatus.Failure)
switch (result.Status)
{
case TestStatus.Failed:
_progressBar.Status = TestProgressBarStatus.Failure;
break;
case TestStatus.Skipped:
if (result.Label == "Invalid")
_progressBar.Status = TestProgressBarStatus.Failure;
else if (result.Label == "Ignored" && currentStatus != TestProgressBarStatus.Warning)
_progressBar.Status = TestProgressBarStatus.Warning;
break;
}
}
示例12: MappingTest
public void MappingTest(string commandLineArguments, ResultState expectedResult, string firstArgumentValue, ParserNotation notation)
{
// Setup
var parser = new CommandParser(notation);
var args = parser.Parse(commandLineArguments);
var configuration = new CommandConfiguration();
configuration.CommandAssemblies.Add(Assembly.GetExecutingAssembly());
var lookup = new CommandLookup(configuration);
var command = lookup.GetCommand(args.First().Key);
Assert.NotNull(args);
Assert.NotNull(command);
// Test
var target = new CommandMapper();
var result = target.Map(args.Skip(1), command.Arguments);
// Assert
Assert.NotNull(result);
Assert.True(result.State == expectedResult);
Assert.True(firstArgumentValue == null || firstArgumentValue == result?.ResultArguments?.First().ToString());
}
示例13: ResultStateToTestOutcome
// Public for testing
public static TestOutcome ResultStateToTestOutcome(ResultState resultState)
{
switch (resultState)
{
case ResultState.Cancelled:
return TestOutcome.None;
case ResultState.Error:
return TestOutcome.Failed;
case ResultState.Failure:
return TestOutcome.Failed;
case ResultState.Ignored:
return TestOutcome.Skipped;
case ResultState.Inconclusive:
return TestOutcome.None;
case ResultState.NotRunnable:
return TestOutcome.Failed;
case ResultState.Skipped:
return TestOutcome.Skipped;
case ResultState.Success:
return TestOutcome.Passed;
}
return TestOutcome.None;
}
示例14: Result
public Result(ResultState state, Coordinate coordinate)
: this(state)
{
Coordinate = coordinate;
}
示例15: SetResult
/// <summary>
/// Set the result of the test.
/// </summary>
/// <param name="resultState">The ResultState to use in the result</param>
/// <param name="ex">The exception that caused this result</param>
public void SetResult(ResultState resultState, Exception ex, FailureSite failureSite)
{
if (resultState == ResultState.Cancelled)
SetResult(resultState, "Test cancelled by user", BuildStackTrace(ex));
else if (resultState == ResultState.Error)
SetResult( resultState, BuildMessage(ex), BuildStackTrace(ex), failureSite);
else
SetResult(resultState, ex.Message, ex.StackTrace, failureSite);
}