Jelajahi Sumber

Added ProcessFileTest

Piotr Czajkowski 2 bulan lalu
induk
melakukan
def6abca4c
1 mengubah file dengan 24 tambahan dan 0 penghapusan
  1. 24 0
      ProcessFilesTests/ProcessFiles_UnitTests.cs

+ 24 - 0
ProcessFilesTests/ProcessFiles_UnitTests.cs

@@ -1,5 +1,6 @@
 using NSubstitute;
 using ProcessFiles.Interfaces;
+using System.IO;
 using Xunit;
 using Xunit.Sdk;
 
@@ -70,5 +71,28 @@ namespace ProcessFilesTests
             fakeFileSystem.File.Received().Exists(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>());
+        }
     }
 }