ProcessFiles_UnitTests.cs 824 B

1234567891011121314151617181920212223242526272829
  1. using NSubstitute;
  2. using ProcessFiles.Interfaces;
  3. using Xunit;
  4. namespace ProcessFilesTests
  5. {
  6. public class ProcessFiles_UnitTests
  7. {
  8. [Fact]
  9. public void ProcessFileNotExistTest()
  10. {
  11. var result = string.Empty;
  12. void TestAction(string value)
  13. {
  14. result = value;
  15. }
  16. var fakeFileSystem = Substitute.For<IFileSystem>();
  17. fakeFileSystem.File.Exists(Arg.Any<string>()).Returns(false);
  18. var test = new ProcessFiles.ProcessFiles(fakeFileSystem);
  19. var errors = test.Process(["./imaginaryFolder/imaginaryTest.txt"], "txt", TestAction);
  20. Assert.NotEmpty(errors);
  21. Assert.Empty(result);
  22. fakeFileSystem.File.Received().Exists(Arg.Any<string>());
  23. }
  24. }
  25. }