-
Notifications
You must be signed in to change notification settings - Fork 337
Replies: 1 comment · 4 replies
-
@endend789 this is likely a configuration issue. Could you provide a reproducible code sample? |
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
@endend789 I tried your code sample and no error was thrown. Are you sure your example reproduces the error? Here's my sample: Tested classpublic class Calculation
{
static void Main() { }
public int FindMax(int[] arr)
{
int max = 0;
for (int i = 0; i < arr.Length; i++)
{
if (max < arr[i])
max = arr[i];
}
return max;
}
public int FindMin(int[] arr)
{
int min = 0;
for (int i = 0; i < arr.Length; i++)
{
if (min > arr[i])
min = arr[i];
}
return min;
}
} [TestClass]
public class CalculationTest
{
private Calculation _testClass;
private IFixture _fixture;
[TestInitialize]
public void SetUp()
{
_fixture = new Fixture().Customize(new AutoMoqCustomization());
_testClass = _fixture.Create<Calculation>(); // <= No exception here
}
[TestMethod]
public void FindMax_MethodBasicTest()
{
// Arrange
var arr = _fixture.Create<int[]>();
// Act
var result = _testClass.FindMax(arr);
// Assert
Assert.AreEqual(arr.Max(), result);
}
[TestMethod]
public void FindMax_MethodArrWithNullTestN()
{
Assert.ThrowsException<NullReferenceException>(() => _testClass.FindMax(default!));
}
[TestMethod]
public void FindMin_MethodBasicTest()
{
// Arrange
var arr = _fixture.Create<int[]>();
// Act
var result = _testClass.FindMin(arr);
// Assert
Assert.AreEqual(arr.Min(), result); // This fails cause the min calculation is bugged.
}
[TestMethod]
public void FindMin_MethodArrWithNullTestN()
{
Assert.ThrowsException<NullReferenceException>(() => _testClass.FindMin(default!));
}
} |
Beta Was this translation helpful? Give feedback.
All reactions
-
here's inner exception message(if its weird sentence, sorry i used translator) Inner exception message: today i changed some things' version and it worked. before(when error occured), i used i modified version(no error). on the inner exception message, there is a 'Moq, Version=4.1.~~'. So i changed it and it worked. |
Beta Was this translation helpful? Give feedback.
All reactions
-
@endend789 the inner exception mentions that the test runner couldn't find the Moq package. AutoFixture is fully compatible with the latest version of Moq so there shouldn't be any issues there. |
Beta Was this translation helpful? Give feedback.
-
I downloaded moq, autofixture, and autofixture.moq to the nuget package and generated test case through Unitverse. And then this message occured.
I asked Unitverse about it and they(Unitverse) said it was not their error, but sound like an issue in autofixture. The test won't proceed due to this error, do you know why?
Beta Was this translation helpful? Give feedback.
All reactions