I found an issue with Long's and Int's being treated as different objects in the Mocks.
Here's my test class:
Here's my test that fails:
If I change "number" to a long the test passes.
This also holds true for this:
My expectations were for int and long to produce the same result since they are "equal" and there is no way to actually pass a true int into that method.
Here's my test class:
public
class
MyClass
{
public
long
AddOne(
long
number)
{
return
number + 1;
}
}
Here's my test that fails:
[TestMethod]
public
void
MyClass_AddOne_mock_test_int()
{
// Arrange
int
number = 5;
int
expectedResult = 42;
var myClass = Mock.Create<MyClass>();
Mock.Arrange(() => myClass.AddOne(number))
.Returns(expectedResult);
// Act
var result = myClass.AddOne(number);
// Assert
Assert.AreEqual(expectedResult, result); // result = 0
}
If I change "number" to a long the test passes.
This also holds true for this:
Mock.Assert(() => myClass.AddOne(number), Occurs.Once());
My expectations were for int and long to produce the same result since they are "equal" and there is no way to actually pass a true int into that method.
[TestMethod]
public
void
Assert_int_vs_long()
{
int
intNumber = 5;
long
longNumber = 5;
Assert.AreEqual(intNumber, longNumber);
}