Browse files

removed that stupid manual mock. what the hell was I thinking???

  • Loading branch information...
1 parent a3da207 commit 8c0f0cd58953b74b863af7d0146a171be669a919 @adrianaisemberg adrianaisemberg committed Oct 25, 2011
Showing with 35 additions and 20 deletions.
  1. +0 −14 Tests/FileSystemMock.cs
  2. +35 −5 Tests/Tests.cs
  3. +0 −1 Tests/Tests.csproj
View
14 Tests/FileSystemMock.cs
@@ -1,14 +0,0 @@
-using CLAP;
-
-namespace Tests
-{
- internal class FileSystemMock : FileSystemHelper.IFileSystem
- {
- public string ReturnValue { get; set; }
-
- public string ReadAllText(string path)
- {
- return ReturnValue;
- }
- }
-}
View
40 Tests/Tests.cs
@@ -1616,67 +1616,95 @@ public void Execute_WithFileInput_String()
{
var s = new Sample_41();
- FileSystemHelper.FileHandler = new FileSystemMock { ReturnValue = "kicks ass!" };
+ var mock = new Mock<FileSystemHelper.IFileSystem>();
+
+ mock.Setup(f => f.ReadAllText("some_dummy_file")).Returns("kicks ass!");
+
+ FileSystemHelper.FileHandler = mock.Object;
Parser.Run(new[]
{
"-str@=some_dummy_file"
}, s);
Assert.AreEqual("kicks ass!", s.Values["str"]);
+
+ mock.VerifyAll();
}
[Test]
public void Execute_WithFileInput_Int()
{
var s = new Sample_41();
- FileSystemHelper.FileHandler = new FileSystemMock { ReturnValue = "567" };
+ var mock = new Mock<FileSystemHelper.IFileSystem>();
+
+ mock.Setup(f => f.ReadAllText("some_dummy_file")).Returns("567");
+
+ FileSystemHelper.FileHandler = mock.Object;
Parser.Run(new[]
{
"-num@=some_dummy_file"
}, s);
Assert.AreEqual(567, s.Values["num"]);
+
+ mock.VerifyAll();
}
[Test]
public void Execute_WithFileInput_Bool()
{
var s = new Sample_41();
- FileSystemHelper.FileHandler = new FileSystemMock { ReturnValue = "false" };
+ var mock = new Mock<FileSystemHelper.IFileSystem>();
+
+ mock.Setup(f => f.ReadAllText("some_dummy_file")).Returns("false");
+
+ FileSystemHelper.FileHandler = mock.Object;
Parser.Run(new[]
{
"-b@=some_dummy_file"
}, s);
Assert.AreEqual(false, s.Values["b"]);
+
+ mock.VerifyAll();
}
[Test]
public void Execute_WithFileInput_Enum()
{
var s = new Sample_41();
- FileSystemHelper.FileHandler = new FileSystemMock { ReturnValue = "Unchanged" };
+ var mock = new Mock<FileSystemHelper.IFileSystem>();
+
+ mock.Setup(f => f.ReadAllText("some_dummy_file")).Returns("Unchanged");
+
+ FileSystemHelper.FileHandler = mock.Object;
Parser.Run(new[]
{
"-c@=some_dummy_file"
}, s);
Assert.AreEqual(Case.Unchanged, s.Values["c"]);
+
+ mock.VerifyAll();
}
[Test]
public void Execute_WithFileInput_Array()
{
var s = new Sample_41();
- FileSystemHelper.FileHandler = new FileSystemMock { ReturnValue = "301,7,99" };
+ var mock = new Mock<FileSystemHelper.IFileSystem>();
+
+ mock.Setup(f => f.ReadAllText("some_dummy_file")).Returns("301,7,99");
+
+ FileSystemHelper.FileHandler = mock.Object;
Parser.Run(new[]
{
@@ -1688,6 +1716,8 @@ public void Execute_WithFileInput_Array()
Assert.AreEqual(301, arr[0]);
Assert.AreEqual(7, arr[1]);
Assert.AreEqual(99, arr[2]);
+
+ mock.VerifyAll();
}
[Test]
View
1 Tests/Tests.csproj
@@ -90,7 +90,6 @@
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
- <Compile Include="FileSystemMock.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Samples.cs" />
<Compile Include="Tests.cs" />

0 comments on commit 8c0f0cd

Please sign in to comment.