由于属性不会继承在C#中(至少我没认为他们做过) - 当运行MyTestMethod
测试时,下面的代码如何仍显示Hello弹出:C#属性不应该继承
[TestClass]
public class BaseTestClass {
[TestInitialize]
public void Foo() {
System.Windows.Forms.MessageBox.Show("Hello");
}
}
[TestClass]
public class TestClass : BaseTestClass {
[TestMethod]
public void MyTestMethod() {
Assert.IsTrue(true);
}
}
它不应该,除非MyTestMethod调用foo,但无关与C#属性,它可以被遗传。 – Firoso 2011-01-05 22:50:04
Foo用TestClass测试继承的[TestInitialize]属性进行装饰。但是,如上所述,属性可以被继承。 – 2011-01-05 22:56:31