Check out this code:
internal static readonly Dictionary<Type, Func<IModel>> typeToCreator = new Dictionary<Type, Func<IModel>>();
protected static object _lock;
public virtual void Register<T>(Func<IModel> creator)
{
lock (_lock)
{
if (typeToCreator.ContainsKey(typeof(T)))
typeToCreator[typeof(T)] = creator;
else
typeToCreator.Add(typeof(T), creator);
}
}
When I use run the code in this test (testframework is MSTest):
[TestMethod]
public void Must_Be_BasePresenterType()
{
var sut = new ListTilbudPresenter(_tilbudView);
Assert.IsInstanceOfType(sut, typeof(BasePresenter));
}
...MSTest passes it and TestDriven.NET fails it because _lock is null.
Why does MSTest NOT fail the test???