chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
The following test throws an expection. I am using Typemock 6.0.4.0
 [Test, Isolated]
        public void MyTest()
        {
            var fakeSqlConnection = Isolate.Fake.Instance<SqlConnection>();
            Isolate.Swap.AllInstances<SqlConnection>().With(fakeSqlConnection);
            Isolate.WhenCalled(() => fakeSqlConnection.Open()).IgnoreCall();

            SqlConnection sqlConnection = new SqlConnection();
            sqlConnection.Open();
        }


Exception
***************************************
System.Reflection.TargetInvocationException occurred
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at f7.b(Boolean A_0)
at f7.g()
at NetQuote.Internet.Tests.Common.Facade.Calling_Application_CheckForDuplicateApplications.MyTest() in C:DataProjectsNetQuote runkNetQuote.Internet.TestsCommonFacadeCalling_Application_CheckForDuplicateApplications.cs:line 41
InnerException: System.InvalidOperationException
Message="The ConnectionString property has not been initialized."
Source="System.Data"
StackTrace:
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()




asked by girubasp (600 points)

1 Answer

0 votes
Hi,

I run the test you posted and it passed.
Can you please tell me what unit test runner are you using?
Are you running the test in 32 bit or 64 bit?
Also please tell me if there is a setup or teardown actions in the test.
answered by ohad (35.4k points)
...