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
Greetings !

We are very much interested in purchasing your Isolator(.Net) product and prototyping for same using evaluation version to test its applicability to our requirements. We need to integrate Isolator(.Net) with Xunit.

But we are unable to use the .Net Isolator evaluation version with xUnit as its giving the following exception while execution

----------------------------------------------------
TypeMock.TypeMockException :
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
* Are you are trying to fake an unsupported mscorlib type? See supported types here: https://www.typemock.com/mscorlib-types
Stack Trace:
at gt.a(cw A_0, Boolean A_1)
at dj.a(Boolean A_0)
at dp.b(Boolean A_0)
at i2.b(Boolean A_0)
at i2.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5)
at i2.b(Object A_0)
at TypeMock.ArrangeActAssert.
ExpectationEngine`1.a(TResult A_0)
-----------------------------------------------------------------------
Kindly help us resolve this issue at the earliest. Thanks
asked by sony (7.2k points)

6 Answers

0 votes
Hello!

Thank you for evaluating and posting!

This exception can be thrown for numerous reasons.
Can you please post your test code here, so we can try and reproduce the problem?

You can also send it to support at typemock.com.

Regards,
Yonatan,
Typemock Support
answered by yonatan (1.6k points)
0 votes
Thanks Yonatan for the quick response. We have created the following method for testing:
----------------------------------
public class MyClass
{
[Isolated]
[Fact]
public void SimpleTestUsingMessageBox()
{
// Arrange
Isolate.WhenCalled(() => MessageBox.Show(string.Empty)).WillReturn(DialogResult.OK);

// Act
MessageBox.Show("This is a message");

// Assert
Isolate.Verify.WasCalledWithExactArguments(() => MessageBox.Show("This is a message"));
}
}
------------------------------------------------------

The above method is giving the following exception

ClassLibrary.Test.MyClass.SimpleTestUsingMessageBox : TypeMock.TypeMockException :
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
* Are you are trying to fake an unsupported mscorlib type? See supported types here: https://www.typemock.com/mscorlib-types
Stack Trace:
at gt.a(cw A_0, Boolean A_1)
at dj.a(Boolean A_0)
at dp.b(Boolean A_0)
at i2.b(Boolean A_0)
at i2.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5)
at i2.b(Object A_0)
at TypeMock.ArrangeActAs

Also, we are trying the below code which is also not running as expected.

-----------------------------------------------------------------
public class MyClassDoSth
{
[Isolated]
[Fact]
public void DoSomething_Call_Success()
{
// Expectations
using (RecordExpectations expect = RecorderManager.StartRecording())
{
MyClassDoSth cls = new MyClassDoSth();
cls.DoSomething("monday", 2);
cls.DoSomething("tuesday", 42);
expect.CheckArguments();

}
MyClassDoSth newClass = new MyClassDoSth();
newClass.DoSomething("saturday", 16); // any parameters
newClass.DoSomething("tuesday", 42); // matching parameters

// Verify
MockManager.Verify();

}
public void DoSomething(string param1, int param2)
{
throw new Exception("Hello from DoSomething!");
}

public MyClassDoSth()
{
throw new Exception("Hello from constructor!");
}
}
Following exception occurred:
---------------------------------------------
ClassLibrary.Test.MyClassDoSth.DoSomething_Call_Success : System.Exception : Hello from constructor!
Stack Trace:
at ClassLibrary.Test.MyClassDoSth..ctor() in D:\Day Users\Sanvirk\Official\Projects\OldProjects\PrototypeTypeMock\ClassLibrary.Test\MyClass.cs:line 59
---------------------------------------------------------------
Also confirm us that the Isolator(TypeMock) can work with xUnit GUI and Command line interface.
Kindly help us regarding the above.
Thanks
[/code]
answered by sony (7.2k points)
0 votes
Hi,

These are two different issues...

The AAA code:
The test passes here, with XUnit - perhaps your test project is called TypemockSomething? if so, it is a known issue - please change the project name to something that does not start with Typemock.

The Natural API code:
You are faking the test class itself - write the code under test in a separate class (as you normally wouldn't write production code in your test clsas) and the test will pass.

You should be able to run test using XUnit and Isolator.

Have fun, and feel free to post here or contact our support mail if you are facing any more issues...

Regards,
Yonatan,
Typemock Support
answered by yonatan (1.6k points)
0 votes
Thanks Yonatan.

We have the following production class:
public class Class1
{
public static int GetValue(int a, int b)
{
return a + b;
}
}

We are testing the above method ‘Class1.GetValue’ using the following test class:

public class TestXUnit
{
[Fact]
public void GetValue_Test()
{
// Arrange
Isolate.WhenCalled(() => Class1.GetValue(1,2)).WillReturn(3);

// Act
int v = Class1.GetValue(1, 2);

// Assert
Assert.Equal(3, v);
}
}


During testing, we are getting the following exception:
------------------------------------------------------------------------------------------

TestProject1.TestXUnit.SimpleTestUsingMessageBox2 : TypeMock.TypeMockException :
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
* Are you are trying to fake an unsupported mscorlib type? See supported types here: https://www.typemock.com/mscorlib-types
Stack Trace:
at gt.a(cw A_0, Boolean A_1)
at dj.a(Boolean A_0)
at dp.b(Boolean A_0)
at i2.b(Boolean A_0)
at i2.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5)
at i2.b(Object A_0)
at TypeMock.ArrangeActAssert.ExpectationEngine`1.a(TResult A_0)
at TestProject1.TestXUnit.SimpleTestUsingMessageBox2() in D:\Day Users\Sanvirk\Official\Projects\OldProjects\TestProject1\TestProject1\Class1.cs:line 18
---------------------------------------------------------------------------------------------------
We are not using ‘Typemock’ in the project Name.
We request you to kindly get us the sample prototype demonstrating .Net Isolator usage with xunit.

Thanks
answered by sony (7.2k points)
0 votes
The error you are getting happens if Isolator is not enabled properly. In your situation, running an external GUI runner, in order to set up the Isolator environment you should run the GUI runner through the supplied TMockRunner.exe. You can find out more about TMockRunner here: http://docs.typemock.com/Isolator/##typemock.chm/Documentation/TMockRunner.html.

In your case it should be something like:
TMockRunner.exe xunit.exe


Hope this helps - please let us know!
Doron
Typemock Support
answered by doron (16.5k points)
0 votes
We are able to test properly. Thanks very much for all your guidance and support.
answered by sony (7.2k points)
...