Reputation: 559
I use (or try) the Silverlight unittesting.
everything seems alright but the methods taged with attribute [TestInitialize]
are not called before the [TestMethod]
. Anyone knows a workaround ?
here is a sample where Method BeforeAnyTest is never called:
[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);
}
}
Upvotes: 4
Views: 451
Reputation: 33272
Try to define it as public
instead of protected
ie:
[TestInitialize]
public void BeforeAnyTest()
{
MockRepository = new MockRepository();
}
Upvotes: 10