Przeglądaj źródła

Stworzono testy dla sprawdzenia zachowń w zależności od rozszerzenia dla DirConverter

Adam Matuszewski 1 rok temu
rodzic
commit
0840e88485

+ 21 - 0
KonwersjaLiter2/src/test/java/pl/dmcs/DirConverterBehaviorTest.java

@@ -57,4 +57,25 @@ public class DirConverterBehaviorTest {
         verify(fileConverter).convertToUpperCase(emptyFilePath.toString());
     }
 
+    @Test
+    void testConvertDirNonExistentDirectory() {
+        Exception exception = assertThrows(IOException.class, () -> {
+            dirConverter.convertDir("non/existent/directory", FILE_EXTENSION);
+        });
+
+    }
+
+    @Test
+    void testConvertDirNonMatchingExtension() throws IOException {
+        Files.write(Paths.get(TEST_DIR, "file1.md"), "markdown content".getBytes());
+
+        dirConverter.convertDir(TEST_DIR, FILE_EXTENSION);
+
+        verify(fileConverter).convertToUpperCase(Paths.get(TEST_DIR, "file1.txt").toString());
+        verify(fileConverter).convertToUpperCase(Paths.get(TEST_DIR, "file2.txt").toString());
+        verify(fileConverter).convertToUpperCase(Paths.get(TEST_DIR, "file3.txt").toString());
+        verify(fileConverter, never()).convertToUpperCase(Paths.get(TEST_DIR, "file1.md").toString());
+    }
+
+
 }