I cannot find a way to actually have my mock work.
Given code like this:
What am I missing? (using NUnit 2.6.2 with the Resharper test runner).
Given code like this:
[Test]
public
void
DirectoryTest()
{
Mock.SetupStatic(
typeof
(Directory), Behavior.CallOriginal, StaticConstructor.Mocked);
Mock.Initialize(
typeof
(Directory));
// w/ or w/o this line - same behavior
Mock.Arrange(() => Directory.GetDirectories(Arg.AnyString, Arg.AnyString, Arg.IsAny<SearchOption>()))
.IgnoreArguments()
// w/ or w/o this line - same behavior
.IgnoreInstance()
// w/ or w/o this line - same behavior
.Returns(() =>
new
[] {
"somedummydirectory"
});
// throws ArgumentNullException here
var test = Directory.GetDirectories(
null
,
"*"
, SearchOption.TopDirectoryOnly).ToList();
Assert.IsNotNull(test);
Assert.AreEqual(1, test.Count);
Assert.AreEqual(
"somedummydirectory"
, test[0]);
}
What am I missing? (using NUnit 2.6.2 with the Resharper test runner).