4

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);
        }
}

1 Answer 1

10

Try to define it as public instead of protected ie:

[TestInitialize]
public void BeforeAnyTest()
{
    MockRepository = new MockRepository();
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.