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

Is struct method faking possible with Isolator? I enjoy using structs in my C# programming for their great field-by-field assertion behavior when used in NUnit.AssertEqual(expectedStruct, actualStruct) statements. I'm seeing with Isolator 7.4.3, as installed from TypemockIsolatorClient7.4.3-TFS2013.1844127947.msi, in VS 2013 Update 4, that methods on classes but not structs can be IgnoreCall()'d and then WasCalledWithExactArguments(). Does a workaround exist that makes struct method faking possible? For reference type versus value type reasons I would imagine implementing struct method faking is rather difficult, but in the spirit of the new year I have my hopes high that the good folks at Typemock have found a way to make this possible!

Code for testing class vs struct faking:

public struct Struct
{
public void Method()
{
OtherMethod();
}
 
public void OtherMethod()
{
}
}
 
public class Class
{
public void Method()
{
OtherMethod();
}
 
public void OtherMethod()
{
}
}
 
[TestFixture, Isolated]
public class Tests
{
[Test]
public void ClassVersusStructMethodFaking()
{
 
var c = new Class();
Isolate.WhenCalled(() => c.OtherMethod()).IgnoreCall();
//
c.Method();
//
// This succeeds
Isolate.Verify.WasCalledWithExactArguments(() => c.OtherMethod());
 
var s = new Struct();
Isolate.WhenCalled(() => s.OtherMethod()).IgnoreCall();
//
s.Method();
//
// This fails TypeMock.VerifyException: TypeMock Verification: Method Struct.OtherMethod() was expected but was not called
Isolate.Verify.WasCalledWithExactArguments(() => s.OtherMethod()); 
}
}
asked by NeilJustice (14.1k points)
reshown by inga
Struct method faking now works in Isolator 8.0.5.2. Thanks Typemock!

4 Answers

0 votes
Hi Neil,

It's a bug, We are working on it.

I'll keep you posted as soon as it solved.
answered by Bar (3.3k points)
Thanks Bar. Good luck solving it.
0 votes

Hi Neil,

We fixed this issue.

Please download the latests version from our website.

Let us know if it helps.

answered by Bar (3.3k points)

Hi Bar,

Thanks for fixing this issue but the latest version, TypemockIsolatorSuite8.0.1.8.1844127947.msi, gives this error when opened:

Also, after uninstalling the previous version, TypemockIsolatorSuite8.0.1.1844127947.msi, the uninstall is not successful, leading to these error messages at start of Visual Studio:

Typemock-related entries in ActivityLog.xml:

<entry>
    <record>43</record>
    <time>2015/02/25 20:47:03.616</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>CreateInstance failed for package [Typemock.VSExtension.TypemockVSExtension, Typemock.VSExtension, Version=8.0.1.0, Culture=neutral, PublicKeyToken=3dae460033b8d8e2]</description>
    <guid>{CBA66BD2-F6DC-459C-BDBA-5533A64DB0A0}</guid>
    <hr>80070002</hr>
    <errorinfo>Could not load file or assembly 'C:\Program Files (x86)\Typemock\Isolator\8.0\Typemock.VSExtension.dll' or one of its dependencies. The system cannot find the file specified.</errorinfo>
  </entry>
  <entry>
    <record>44</record>
    <time>2015/02/25 20:47:03.616</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>End package load [Typemock.VSExtension.TypemockVSExtension, Typemock.VSExtension, Version=8.0.1.0, Culture=neutral, PublicKeyToken=3dae460033b8d8e2]</description>
    <guid>{CBA66BD2-F6DC-459C-BDBA-5533A64DB0A0}</guid>
    <hr>80004005 - E_FAIL</hr>
    <errorinfo>Could not load file or assembly 'C:\Program Files (x86)\Typemock\Isolator\8.0\Typemock.VSExtension.dll' or one of its dependencies. The system cannot find the file specified.</errorinfo>
  </entry>
0 votes

 

It looks like a deployment issue, we are working on it.

 

You can use this workaround for now:

Please uninstall Isolator, then open command prompt(as administrator) from: Visual Studio folderCommon7IDE and run devenv.exe /setup.

Please wait until devenv.exe process ends and then install v8.0.1.8.

 

Let us know if it helps.

answered by Bar (3.3k points)

devenv.exe /setup worked to clear the partial uninstallation. Upon reinstall of v8.0.1.8 with the fixed .msi file, I am now seeing this:

------ Test started: Assembly: IBStratBench.Tests.dll ------
 
Test 'MainFormTests.buttonTest1_Click_CallsServicesTest1' failed: SetUp : System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.GdipGetLogFontW<<Swapped(HandleRef , HandleRef , Object )
at System.Drawing.SafeNativeMethods.Gdip.GdipGetLogFontW(HandleRef font, HandleRef graphics, Object lf)
at System.Drawing.Font.ToLogFont(Object logFont, Graphics graphics)
at System.Drawing.Font.ToLogFont(Object logFont)
at System.Drawing.Font.ToHfont()
at System.Windows.Forms.Control.FontHandleWrapper..ctor(Font font)
at System.Windows.Forms.Control.GetDefaultFontHandleWrapper()
at System.Windows.Forms.Control.get_FontHandle()
at System.Windows.Forms.ListView..ctor()
IBStratBenchMainForm.Designer.cs(40,0): at IBStratBenchMainForm.InitializeComponent()
IBStratBenchMainForm.cs(12,0): at IBStratBenchMainForm..ctor(Services services)
MainFormTests.cs(23,0): at MainFormTests.SetUp()
at TypeMock.MockManager.getReturn(Object context, String typeName, String methodName, Object methodGenericParams, Boolean isDecorated, Boolean isInterceptedType, Object[] methodArguments)
at Typemock.Interceptors.Profiler.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
MainFormTests.cs(17,0): at MainFormTests.SetUp()
 
0 passed, 1 failed, 0 skipped, took 4.01 seconds (NUnit 2.6.4).
 
0 votes
This issue was solved in later versions
answered by Bar (3.3k points)
...