MSTestのTestMethods間で状態を共有するにはどうすればよいですか。これらのテストは、順序付きテストとして順番に実行されます。
private TestContext testContext;
public TestContext TestContext
{
get { return this.testContext; }
set { this.testContext = value;}
}
[TestMethod]
public void Subscribe()
{
bool subscribed = true;
TestContext.Properties.Add("subscribed", subscribed);
Assert.IsTrue(subscribed == true, string.Format("Subscribed...{0}", this.GetHashCode()));
}
[TestMethod]
public void GenerateEvent()
{
bool subscribed = (bool)TestContext.Properties["subscribed"];
Assert.IsTrue(subscribed == true, string.Format("Subscribed...{0}", this.GetHashCode()));
}
前もって感謝します。