public
class
Context
{
public
IList<
int
> myList =
new
List<
int
>();
public
void
PopulateList(
int
count)
{
for
(
int
i = 0; i < count; i++)
{
this
.myList.Add(i);
}
}
}
...
[TestMethod]
public
void
MockConcreteInstance_And_ValidateOccurance()
{
var expectedOccurrences = 10;
// ARRANGE
// Creating a mock instance of the "Context" class with Behavior.CallOriginal.
var foo = Mock.Create<Context>(Behavior.CallOriginal);
// Arranging: foo.myList.Add() should be called expected number of times no matter the argument.
Mock.Arrange(()=> foo.myList.Add(Arg.AnyInt)).Occurs(expectedOccurrences);
// ACT
foo.PopulateList(expectedOccurrences);
// ASSERT
Mock.Assert(foo);
}
Purchase individual products or any of the bundles
With dedicated technical support.