我有以下测试夹具类,出于我以外的原因,NUnit 决定围绕这个而不是这个运行所有测试类
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using MyProject;
using NUnit.Framework;
namespace MyProject.Test
{
[TestFixture]
public class MyProjectTests
{
private const string Description = "This is a test Description generated through UNIT Tests";
private ManualWorkflowSchedulerService scheduler;
private WorkflowRuntime workflowRuntime;
[SetUp]
public void Init()
{
// set up workflow scheduler and runtime
this.workflowRuntime = new WorkflowRuntime();
this.scheduler = new ManualWorkflowSchedulerService(true); // run synchronously
this.workflowRuntime.AddService(this.scheduler);
this.workflowRuntime.StartRuntime();
// create Test Case Sources
object[] insertScenarios =
{
new object[] { typeof(RaiseScenario), this.workflowRuntime, Description, true, true, string.Empty },
new object[] { typeof(RaiseScenario), this.workflowRuntime, Description, true, false, "New Reason" }
};
}
/// <summary>
/// The insert tests.
/// </summary>
/// <param name="runtime">
/// The runtime.
/// </param>
/// <param name="description">
/// The description.
/// </param>
/// <param name="outstandingWorkDocUploaded">
/// The Doc One Uploaded.
/// </param>
/// <param name="DocTwoUploaded">
/// The Doc Two Uploaded.
/// </param>
/// <param name="shortageReason">
/// The shortage Reason.
/// </param>
[Test, TestCaseSource("insertScenarios")]
public void TestInsert(
WorkflowRuntime runtime,
string description,
bool DocOneUploaded,
bool DocTwoUploaded,
string Reason)
{
var message = Business.InsertBoatHandoverOutsideCrew(runtime, description, DocOneUploaded, DocTwoUploaded, Reason);
Assert.AreNotEqual(0, message.Id);
}
}
}
测试项目的结构分为多个组成部分,即解决方案的每个子项目在测试项目中都有自己的目录。这对于 .Net 3.5 中编码的所有其他项目都不是问题,但现在忽略了该项目的测试。
请您参考如下方法:
如果您从 SetUp
// create Test Case Sources
public object[] insertScenarios =
{
new object[] { typeof(RaiseScenario), this.workflowRuntime, Description, true, true, string.Empty },
new object[] { typeof(RaiseScenario), this.workflowRuntime, Description, true, false, "New Reason" }
};
/// <summary>
/// The init.
/// </summary>
[SetUp]
public void Init()
{
// set up workflow scheduler and runtime
this.workflowRuntime = new WorkflowRuntime();
this.scheduler = new ManualWorkflowSchedulerService(true); // run synchronously
this.workflowRuntime.AddService(this.scheduler);
this.workflowRuntime.StartRuntime();
}
