Note that there are some explanatory texts on larger screens.

plurals
  1. POCurious problem with NUnit and Typemock
    primarykey
    data
    text
    <p>Using VS 2010, NUnit, Typemock, Entity Framework...</p> <p>I am having a bit of an odd problem using NUnit/Typemock. I am relative new to the testing world so it could be a beginners mistake. This is the problem I am having.</p> <ul> <li>Test Project is compiled.</li> <li>Launch NUnit from within Visual Studio</li> <li>Run tests from within NUnit client app. First run, first test always fails.</li> <li>Rerun and test passes.</li> </ul> <p>It does not matter what test is first. I can select a particular test. If it is the first one to run, it fails on first execution. It passes on rerun.</p> <p>This is an example class having the problem. But the class doesn't matter. Whatever test is run first has this problem. The exception code was just something that was there to test Typemock being loaded. It fails on the WhenCalled.</p> <pre><code>[TestClass, Isolated] public class FirstTest { [TestMethod] public void TestMe() { Exception e = new TypeMock.ArrangeActAssert.NestedCallException(); Isolate.WhenCalled(() =&gt; UnitOfWorkManager.GetCurrentSession(null)).WillReturn(null); Assert.IsTrue(true); } } </code></pre> <p>The following is the error message.</p> <hr> <p>HCSO.ESL.Test.Fakes.FirstTest.TestMe: TypeMock.ArrangeActAssert.NestedCallException : <em>*</em> WhenCalled does not support using a property call as an argument. - To fix this pass false instead of AssemblyReader.IsDotNetFile</p> <hr> <ul> <li>Example - this would work:</li> <li>MyObj argument = Something.Other().GetStuff();</li> <li><p>Isolate.WhenCalled(() => ObjUnderTest.MethodUnderTest(argument))...;</p> <hr></li> <li><p>Example - this would not work:</p></li> <li>Isolate.WhenCalled(() => ObjUnderTest.MethodUnderTest(Something.Other().GetStuff()))...;</li> </ul> <p>(End error message)</p> <hr> <p>Anyone have an idea why the first test always fails but runs fine on rerun? Something with how the assemblies are being loaded?</p> <p>(Edit)Additional Details:</p> <hr> <p>Versions: Typemock Isolator: 6.0.10.0 Visual Studio: 10.0.30319.1</p> <p>In addition, I added simplified test code. This way you can see the code being tested. And yes, this test fails first time, passes on every run after that.</p> <pre><code>[TestClass, Isolated] public class FirstTest { public static int DummyCall(int i) { return 0; } [TestMethod] public void TestMe() { Exception e = new TypeMock.ArrangeActAssert.NestedCallException(); //Isolate.WhenCalled(() =&gt; UnitOfWorkManager.GetCurrentSession(null)).WillReturn(null); Isolate.WhenCalled(() =&gt; FirstTest.DummyCall(-1)).WillReturn(1); Assert.IsTrue(true); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload