From f9a068a780b23cbc8db01c66be7ecc8e0af947b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Sedl=C3=A1=C4=8Dek?= Date: Wed, 30 Aug 2023 23:30:12 +0200 Subject: [PATCH] Fix formatting, fix scanner bug --- FolderSync/Program.cs | 1 - FolderSync/Scanner.cs | 5 +++-- FolderSyncTests/InputHandlerTests.cs | 2 +- FolderSyncTests/WithLogTests.cs | 14 +++++--------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/FolderSync/Program.cs b/FolderSync/Program.cs index 46a3bd2..911018e 100644 --- a/FolderSync/Program.cs +++ b/FolderSync/Program.cs @@ -32,5 +32,4 @@ private static void StopSyncLoopOnThread(SyncLoop syncLoop, Thread thread) { while (thread.IsAlive) Thread.Sleep(200); } - } diff --git a/FolderSync/Scanner.cs b/FolderSync/Scanner.cs index d4d5445..9a2cc0c 100644 --- a/FolderSync/Scanner.cs +++ b/FolderSync/Scanner.cs @@ -42,9 +42,10 @@ private void ProcessSubfolders(Folder folder, Queue foldersToSolve) { } } private void ProcessFilesInFolder(Folder folder) { - if (!TryGetFilesPaths(folder.Path, out var filePaths)) + if (!TryGetFilesPaths(folder.Path, out var filesPaths)) + return; + if (filesPaths == null) return; - var filesPaths = Directory.GetFiles(folder.Path); foreach (var filePath in filesPaths) ScanAndAddFileToFolder(filePath, folder); } diff --git a/FolderSyncTests/InputHandlerTests.cs b/FolderSyncTests/InputHandlerTests.cs index 130bef4..eef34cd 100644 --- a/FolderSyncTests/InputHandlerTests.cs +++ b/FolderSyncTests/InputHandlerTests.cs @@ -3,7 +3,7 @@ namespace FolderSyncTests { [TestClass] public class InputHandlerTests { - private static string baseDir = AppDomain.CurrentDomain.BaseDirectory; + private static readonly string baseDir = AppDomain.CurrentDomain.BaseDirectory; [TestMethod] public void InputHandlerNullArgumentsTest() { Assert.IsFalse(InputHandler.HandleInput(null!)); diff --git a/FolderSyncTests/WithLogTests.cs b/FolderSyncTests/WithLogTests.cs index 33ec6eb..2c11411 100644 --- a/FolderSyncTests/WithLogTests.cs +++ b/FolderSyncTests/WithLogTests.cs @@ -3,22 +3,18 @@ namespace FolderSyncTests { [TestClass] - public class WithLogTests - { - private static WithLog mockWithLog = new MockWithLog(); + public class WithLogTests { + private readonly static WithLog mockWithLog = new MockWithLog(); - public class MockWithLog : WithLog - { + public class MockWithLog : WithLog { } [TestMethod] - public void CreateMockWithLogTest() - { + public void CreateMockWithLogTest() { var withLog = new MockWithLog(); Assert.IsNotNull(withLog); } [TestMethod] - public void WithLogAddNullListenerTest() - { + public void WithLogAddNullListenerTest() { Assert.ThrowsException(() => { mockWithLog.AddLogListener(null!); }); } }