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
Hi,

I have a problem when running the following test. It works when I run it using TestDriven.NET, but not when using Resharper. I have no idea if it's a resharper problem or a typemock problem, so I'm posting here:


      class Test
      {
         public void DoSomething()
         {
            XmlDocument doc = new XmlDocument();
            doc.Save("bork");
         }
      }

      [Test]
      [VerifyMocks]
      public void SimpleTest()
      {
         using (RecordExpectations recorder = RecorderManager.StartRecording())
         {
            XmlDocument doc = new XmlDocument();

            doc.Save("bork");
            recorder.CheckArguments();
         }

         Test test = new Test();
         test.DoSomething();
      }


It fails with an exception:

TestSceneAsset.SaveFileSaves : FailedSystem.Xml.XmlException: Invalid XML document, The document does not have a root element..
at System.Xml.XmlDocument.Save(String filename)
at SiegeManaged.Editor.Model.SceneAsset.SaveFile(String path) in SceneAsset.cs: line 85
at SiegeManaged.Editor.Test.Model.TestSceneAsset.SaveFileSaves() in TestSceneAsset.cs: line 71
at TypeMock.MethodDecorator.CallRealMethod()
at TypeMock.DecoratorAttribute.CallDecoratedMethod()
at TypeMock.VerifyMocksAttribute.Execute()
at TypeMock.DecoratorAttribute.CallDecoratedMethod()
at TypeMock.ClearMocksAttribute.Execute()
at TypeMock.MethodDecorator.d()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
at SiegeManaged.Editor.Test.Model.TestSceneAsset.SaveFileSaves() in TestSceneAsset.cs: line 59 


So it looks like the new XmlDocument is not being mocked. Is there something I'm doing wrong here?

Cheers,

Rory
asked by rorydriscoll (3.8k points)

5 Answers

0 votes
Hi Rory
What you are doing is OK and should path the test.
We'll have to investigate to see where is the problem.

Please send me the Typemock logs.
I'll send you a mail with instructions how to generate them.
answered by ohad (35.4k points)
0 votes
Hi Rory,

We've investigated it a bit, and it turns out that the JetBrains team changed the name of the test runner in version 3, which has some impact on Typemock.

Here's how you solve this:
In the Typemock installation directory ('Program filesTypeMockTypeMock.Net) there's a file named "namespaces.dat". Open it with your favorite editor, and add this line:

JetBrains.ReSharper.TaskRunner.exe

Save it. This should do the work.
Let me know how it works out.
answered by gilz (14.5k points)
0 votes
Oh, that works. Thanks!
________
Honda GL1100A
answered by rorydriscoll (3.8k points)
0 votes
You're welcome!
answered by gilz (14.5k points)
0 votes
Hi,

We have inlcued this fix in the 4.2 version.
answered by lior (13.2k points)
...