Reputation: 356
I'm attempting to unit test a method that loads an Image (of type Image, not the file path) onto a Virtual machine stack.
I have a Verify
call that looks like this:
mockVM.Verify(q => q.Stack.Push(It.IsAny<Image>()), Times.AtLeastOnce());
In order to check wether the following Stack.Push
call occurred in the method under test. The pertinent parts of this method are thus:
Image newImage = Image.FromFile(@"" + Operands[0]);
VirtualMachine.Stack.Push(newImage);
Console.WriteLine("Hit loadimage");
In the class under test I am using System.Drawing
perfectly fine in order to use Image as a type.
However in the Unit test code, despite using System.Drawing
or any variant, I get an error under Image in It.IsAny<Image>()
.
The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)
I want to verify that an object of type image was placed on the stack, but not being able to use Image
as a type is a problem and I can't progress.
Is there some reason why I can't use System.Drawing
in the unit test? Or is there an easy way to achieve my aim.
Upvotes: 2
Views: 1303
Reputation: 13765
System.Drawing
is likely not an included by default as a reference of your unit test project, where it would most likely be included by default for other project types.
Ensure you have a reference to System.Drawing
in your unit test project, then you should be able to resolve Image
after using the appropriate namespace.
Example using default references for a new project and unit test project:
Upvotes: 2