4
我使用(或嘗試)Silverlight單元測試。silverlight UnitTesting不會調用TestInitialize
一切看起來都沒問題,但在[TestMethod]
之前沒有調用屬性爲[TestInitialize]
的方法。任何人都知道解決方法?
這裏是其中的方法BeforeAnyTest不會被調用示例:
[TestClass]
public class TViewModel
{
protected MockRepository MockRepository { get; set; }
/// <summary>
/// This is strangely not called automatically before any test
/// </summary>
[TestInitialize]
protected void BeforeAnyTest()
{
MockRepository = new MockRepository();
}
[TestMethod]
public void TServerStartupViewModelCtor()
{
//BeforeAnyTest();
var smsa = MockRepository.StrictMock<IServerManagementServiceAgent>();
ServerStartupViewModel ssvm = new ServerStartupViewModel(smsa);
Assert.IsNotNull(ssvm);
}
}
這是它,THX! – 2011-03-04 16:32:01
謝謝。它也解決了我的問題(+1) – 2011-04-18 06:14:23