Hello,
I'm in the process of evaluating TypeMock. I've made some tests using Isolator and they run fine the first time. Every time I run them afterwards they always fail complaining about a NullException. I'm facking calls to the SqlConnection class to make it throw an error:
[TestMethod, Isolated]
public void TestConnectionPassesMock()
{
CachingService fakeCachingService = CreateMockCachingService();
var fakeSqlConnection = Isolate.Fake.Instance<System>();
Isolate.Swap.AllInstances<System>().With(fakeSqlConnection);
Isolate.WhenCalled(() => fakeSqlConnection.Open()).IgnoreCall();
var accessor = CachingService_Accessor.AttachShadow(fakeCachingService);
accessor.TestConnection();
}
Error:
Test method VehiclesServiceLayer.Tests.Services.TypeMockTests.TestConnectionPassesMock threw exception: System.NullReferenceException: Object reference not set to an instance of an object..
Stack Trace:
System.Data.Common.DbConnectionOptions.ValidateKeyValuePair(String keyword, String value)
System.Data.Common.DbConnectionStringBuilder.set_Item(String keyword, Object value)
System.Data.SqlClient.SqlConnectionStringBuilder.SetValue(String keyword, String value)
System.Data.SqlClient.SqlConnectionStringBuilder.set_DataSource(String value)
System.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
CachingService.TestConnection() in
<my>
Any idea what's going on?
PS: there's a typo in the mail confirmation for the registration ;)