I have a test that passes 100% time in Visual Studio 2005. When I attempt to run it through the command line using NCover, it fails 100% of the time.
I have tried all the following calling syntaxes:
TMockRunner -first -link NCover ncover.console.exe nunit-console.exe Maestro.nunit /noshadow /xml:c:cc ests.xml
ncover.console.exe nunit-console.exe Maestro.nunit /noshadow /xml:c:cc ests.xml //a MaestroModel_UT
nunit-console.exe Maestro.nunit /noshadow /xml:c:cc ests.xml
I have tried it with and without NCover linked to TypeMock through the configuration utility.
The Test:
[Test]
public void canCreate4DataTablesWhenConfigAsksForThem() {
MockManager.Init();
MaestroModel model = new MaestroModel();
DataStructureCreator creator = new DataStructureCreator();
DataTable stationTable = creator.getChildDataTableWithASingleStation();
GridConfigurationData configurationData = getGridConfigurationData();
using(RecordExpectations recorder = RecorderManager.StartRecording()) {
recorder.DefaultBehavior.RepeatAlways();
MaestroDataReaderFactory dataReaderFactory = new MaestroDataReaderFactory();
IMaestroDataReader dataReader = dataReaderFactory.createMaestroDataReader(MaestroDataReaderFactory.DataReaderTypes.DirectSqlDataReader);
recorder.Return(new DirectSqlDataReader());
DataTable readings = dataReader.GetAllCurrentReadingsByStationID(1);
recorder.Return(stationTable);
}
List <DataTable> tables = model.getSiteStatusTables(1, 99, "Middle Earth", configurationData);
Assert.AreEqual(7, tables.Count);
MockManager.Verify();
}
The Result:
Failures:
1) QTT.Maestro.Model.Test.MaestroModel_UT.canCreate4DataTablesWhenConfigAsksForThem : System.NullReferenceException : Object reference not set to an instance of an object.
at System.Data.SqlClient.SqlConnection.SetInnerConnectionEvent(DbConnectionInternal to)
at System.Data.SqlClient.SqlConnectionFactory.SetInnerConnectionEvent(DbConnection owningObject, DbConnectionInternal to)
at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlInternalConnection.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Close()
at QTT.Maestro.Model.DataAccess.DirectSqlDataReader.getDataTable(SqlConnection connection, SqlCommand command, String tableName) in C:MaestroTrunkProjectsMaestroModelDataAccessDirectSqlDataReader.cs:line 35
at QTT.Maestro.Model.DataAccess.DirectSqlDataReader.GetAllCurrentReadingsByStationID(Int32 stationID) in C:MaestroTrunkProjectsMaestroModelDataAccessDirectSqlDataReader.cs:line 24
at QTT.Maestro.Model.MaestroModel.getSiteStatusTables(Int32 stationGroupID, Int32 stationID, String stationGroupName, GridConfigurationData gridConfigurationData) in C:MaestroTrunkProjectsMaestroModelMaestroModel.cs:line 57
at QTT.Maestro.Model.Test.MaestroModel_UT.canCreate4DataTablesWhenConfigAsksForThem() in C:MaestroTrunkProjectsTe
stsMaestroModel_UTMaestroModel_UT.cs:line 34
I am using :
TypeMock 4.0.3.0 Enterprise
NCover 1.5.8.0
NUnit 2.4.1
Visual Studio 2005
Framework 2.x
OS Microsoft Server 2003
Sure could use some help on this one.