I have this class:
public class TestClass { public TestClass(int? foo, string bar) {
I am trying to mock this with an MOQ like this
var mockA = new Mock<A>(new object[] {(int?)1, string.Empty})
or that,
var mockA = new Mock<A>(new object[] {1 as int?, string.Empty})
even this one
var mockA = new Mock<A>(new object[] {(int?)null, string.Empty})
When I try to get an object like this
var objA = mockA.Object
he throws this exception
Unable to instantiate class: TestClass. Could not find a constructor that matches the given arguments: System.Int32, System.String
(for the third, it throws a null reference exception)
How to make it recognize that the first argument is of type Nullable System.Int32, not System.Int32.
(Please ignore that I am mocking the class, not the interface.)
source share