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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I am a brand new Typemock user so please excuse any stupid usage in advance!

Some of our user interface & algorithmic unit tests require complex data structures, which we want to load out of a database using our standard database load codes. We use LINQ to SQL for data retrieval, for example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Security.Permissions;
using System.Threading;
using System.Collections.ObjectModel;

using NUnit.Framework;
using TypeMock.ArrangeActAssert;

namespace ClassLibrary1

    [TestFixture, Isolated]
    [Description("Tests the operation of the class")]
    public class ClassLibrary1
        [Description("Tests the DB data retrieval")]
        [Property("TestId", 001)]
        public void TestDBConnection()
            DataClasses1DataContext dbctx = new DataClasses1DataContext();
            var res = (from x in dbctx.Table_1s select x);

This is obviously a very simple test, but code like it is called all over the place in our real app.

The problem is that for any LINQ statement -- one that is NOT isolated or mocked -- I am getting the following exception when running NUnit w/ Typemock and it's hooked up to the VS debugger:

System.AccessViolationException : Attempted to Read or Write Protected Memory. This is often an indication that other memory is corrupt.

It happens on the LINQ line using "select" (or happened if using "where" also). It means I cannot load my data for most complex unit tests.

If I run not attached to the debugger, it hard-crashes NUnit.

Other information --

I am using the following .bat file to load tests for running:
cd C:Program Files (x86)TypemockIsolator.0
call mocking_on.bat
TMockRunner &"C:Program Files (x86)NUnit 2.5in
unit.exe" &"C:TypeMock Unit Test IssueClassLibrary1ClassLibrary1inDebugClassLibrary1.dll"
call mocking_off.bat

I do not have any mocked objects in the test project I wrote for this issue. The TextFixture is Isolated and the TypeMock.ArrangeActAssert namespace is referenced, but that's it. I'm running into this simply by running Nunit via Typemock.

If I take out the TypeMock references, and then run the LINQ code using NUnit alone, the tests run beautifully. No problems there, so it's got to be something with the TypeMock runner.

We use SQL Server 2008 for our DB.

I am NOT looking for a solution with mocking the data context. I want to use the real data context and database for some of my tests.

This is a serious issue for me, as I cannot load in our main data structures used for testing our app, so I am "stuck." I cannot imagine that running w/ TypeMock doesn't support this, as it's very basic code, so I must be doing something wrong. Any help would be greatly appreciated! Thanks!
asked by mes (600 points)

1 Answer

0 votes

We are aware of this problem and working to solve it.
We'll notify once a fix will be ready.
answered by ohad (35.4k points)