RajOpteamix / moq

Automatically exported from code.google.com/p/moq
Other
0 stars 0 forks source link

Verify cannot handle generics of type struct #355

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I create a mock of the following class which contains a method using a 
generic T of type struct.

public interface ITest
{
   void Call<T>(T e) where T : struct;
}

2. I try to verify the call

var mock = new Mock<ITest>();
var test = mock.Object;
test.Call(12D);
mock.Verify(f=>f.Call(12), Times.Once());

What is the expected output? What do you see instead?

I expect that the verification is positive but it fails.

What version of the product are you using? On what operating system?

4.0.10827

Please provide any additional information below.

1. If the parameter T is defined on class/interface level the problem does not 
occurrs.

public interface ITest<T> where T : struct

2. Without generics it also works.

Original issue reported on code.google.com by Sven.Kro...@googlemail.com on 28 Nov 2012 at 12:15

GoogleCodeExporter commented 9 years ago
Sorry there is a mistake in the code sample but the bug is there. I attach the 
correct code sample.

Original comment by Sven.Kro...@googlemail.com on 28 Nov 2012 at 12:20

Attachments: