|
@@ -1,5 +1,6 @@
|
|
using NSubstitute;
|
|
using NSubstitute;
|
|
using ProcessFiles.Interfaces;
|
|
using ProcessFiles.Interfaces;
|
|
|
|
+using System.IO;
|
|
using Xunit;
|
|
using Xunit;
|
|
using Xunit.Sdk;
|
|
using Xunit.Sdk;
|
|
|
|
|
|
@@ -70,5 +71,28 @@ namespace ProcessFilesTests
|
|
fakeFileSystem.File.Received().Exists(Arg.Any<string>());
|
|
fakeFileSystem.File.Received().Exists(Arg.Any<string>());
|
|
fakeFileSystem.Path.Received().GetExtension(Arg.Any<string>());
|
|
fakeFileSystem.Path.Received().GetExtension(Arg.Any<string>());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ [Fact]
|
|
|
|
+ public void ProcessFileTest()
|
|
|
|
+ {
|
|
|
|
+ var result = string.Empty;
|
|
|
|
+ void TestAction(string value)
|
|
|
|
+ {
|
|
|
|
+ result = value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var fakeFileSystem = Substitute.For<IFileSystem>();
|
|
|
|
+ fakeFileSystem.File.Exists(Arg.Any<string>()).Returns(true);
|
|
|
|
+ fakeFileSystem.Path.GetExtension(Arg.Any<string>()).Returns("txt");
|
|
|
|
+
|
|
|
|
+ var expectedValue = "imaginary.txt";
|
|
|
|
+ var test = new ProcessFiles.ProcessFiles(fakeFileSystem);
|
|
|
|
+ var errors = test.Process([expectedValue], "txt", TestAction);
|
|
|
|
+ Assert.Empty(errors);
|
|
|
|
+ Assert.Equal(expectedValue, result);
|
|
|
|
+
|
|
|
|
+ fakeFileSystem.File.Received().Exists(Arg.Any<string>());
|
|
|
|
+ fakeFileSystem.Path.Received().GetExtension(Arg.Any<string>());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|