From cdea6281d26f2a2c4b897738f73172e569aa1c4b Mon Sep 17 00:00:00 2001 From: bygu4 Date: Thu, 31 Oct 2024 17:55:02 +0300 Subject: [PATCH 1/6] add check sum evaluator --- Tasks/Test1/Test1.sln | 22 +++++++ Tasks/Test1/Test1/Class1.cs | 113 +++++++++++++++++++++++++++++++++ Tasks/Test1/Test1/Test1.csproj | 10 +++ 3 files changed, 145 insertions(+) create mode 100644 Tasks/Test1/Test1.sln create mode 100644 Tasks/Test1/Test1/Class1.cs create mode 100644 Tasks/Test1/Test1/Test1.csproj diff --git a/Tasks/Test1/Test1.sln b/Tasks/Test1/Test1.sln new file mode 100644 index 0000000..25626cf --- /dev/null +++ b/Tasks/Test1/Test1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test1", "Test1\Test1.csproj", "{E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Tasks/Test1/Test1/Class1.cs b/Tasks/Test1/Test1/Class1.cs new file mode 100644 index 0000000..b797355 --- /dev/null +++ b/Tasks/Test1/Test1/Class1.cs @@ -0,0 +1,113 @@ +// Copyright (c) 2024 +// +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +using System.Security.Cryptography; +using System.Text; + +namespace Test1; + +/// +/// Class for evaluating file chack sum. +/// +public static class CheckSumEvaluator +{ + /// + /// Evaluate the check sum of given file sequentially. + /// + /// Path of the file to get check sum of. + /// An array of bytes: evaluated check sum. + /// File was not found. + public static byte[] GetCheckSumSequentially(string path) + { + if (File.Exists(path)) + { + return GetFileCheckSumSequentially(path); + } + + if (Directory.Exists(path)) + { + return GetDirectoryCheckSumSequentially(path); + } + + throw new FileNotFoundException(); + } + + /// + /// Evaluate the check sum of given file concurrently. + /// + /// Path of the file to get check sum of. + /// A task with result as an array of bytes: evaluated check sum. + /// File was not found. + public static async Task GetCheckSumConcurrently(string path) + { + if (File.Exists(path)) + { + return await GetFileCheckSumConcurrently(path); + } + + if (Directory.Exists(path)) + { + return GetDirectoryCheckSumConcurrently(path); + } + + throw new FileNotFoundException(); + } + + private static byte[] GetFileCheckSumSequentially(string path) + { + var content = File.ReadAllBytes(path); + return MD5.HashData(content); + } + + private static byte[] GetDirectoryCheckSumSequentially(string path) + { + var result = new List(); + var name = Path.GetFileName(path); + var nameHash = MD5.HashData(Encoding.Unicode.GetBytes(name)); + result.AddRange(nameHash); + foreach (var entry in Directory.GetFileSystemEntries(path)) + { + result.AddRange(GetCheckSumSequentially(entry)); + } + + return result.ToArray(); + } + + private static async Task GetFileCheckSumConcurrently(string path) + { + var content = await File.ReadAllBytesAsync(path); + return MD5.HashData(content); + } + + private static byte[] GetDirectoryCheckSumConcurrently(string path) + { + var tasks = new List>(); + var name = Path.GetFileName(path); + tasks.Add(Task.Run(() => MD5.HashData(Encoding.Unicode.GetBytes(name)))); + foreach (var entry in Directory.GetFileSystemEntries(path)) + { + tasks.Add(GetCheckSumConcurrently(entry)); + } + + int size = 0; + foreach (var task in tasks) + { + size += task.Result.Length; + } + + var result = new byte[size]; + for (int taskI = 0; taskI < tasks.Count; ++taskI) + { + var task = tasks[taskI]; + for (int i = 0; i < task.Result.Length; ++i) + { + result[i] = task.Result[i]; + } + } + + return result; + } +} diff --git a/Tasks/Test1/Test1/Test1.csproj b/Tasks/Test1/Test1/Test1.csproj new file mode 100644 index 0000000..3652ffa --- /dev/null +++ b/Tasks/Test1/Test1/Test1.csproj @@ -0,0 +1,10 @@ + + + net8.0 + enable + enable + + + + + \ No newline at end of file From e1a9db3605f03cc6483df67d13942fb59397a5c0 Mon Sep 17 00:00:00 2001 From: bygu4 Date: Thu, 31 Oct 2024 18:34:00 +0300 Subject: [PATCH 2/6] add tests, debug --- Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs | 28 +++++++++++++++++ Tasks/Test1/Test1.Tests/GlobalUsings.cs | 1 + Tasks/Test1/Test1.Tests/Test1.Tests.csproj | 30 +++++++++++++++++++ .../Test1.Tests/TestFiles/Test1/testFile1 | 3 ++ .../Test1.Tests/TestFiles/Test2/testFile1 | 3 ++ .../Test1.Tests/TestFiles/Test2/testFile2 | 4 +++ .../TestFiles/Test3/testFirectory1/testFile1 | 1 + .../TestFiles/Test4/testDirectory1/testFile1 | 1 + .../TestFiles/Test4/testDirectory2/testFile2 | 1 + .../TestFiles/Test4/testDirectory2/testFile3 | 1 + Tasks/Test1/Test1.sln | 10 +++++++ .../Test1/{Class1.cs => CheckSumUtils.cs} | 30 ++++++++++++------- 12 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs create mode 100644 Tasks/Test1/Test1.Tests/GlobalUsings.cs create mode 100644 Tasks/Test1/Test1.Tests/Test1.Tests.csproj create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test1/testFile1 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile1 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile2 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test3/testFirectory1/testFile1 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory1/testFile1 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile2 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile3 rename Tasks/Test1/Test1/{Class1.cs => CheckSumUtils.cs} (80%) diff --git a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs new file mode 100644 index 0000000..25e886c --- /dev/null +++ b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2024 +// +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +namespace CheckSum.Tests; + +public class CheckSumUtilsTest +{ + private const string TestFilesPath = "TestFiles/"; + + public static IEnumerable TestCases() + { + foreach (var testDirectory in Directory.GetDirectories(TestFilesPath)) + { + yield return new TestCaseData(testDirectory); + } + } + + [TestCaseSource(nameof(TestCases))] + public async Task TestCheckSumEvaluation(string path) + { + var hash1 = CheckSumUtils.GetCheckSumSequentially(path); + var hash2 = await CheckSumUtils.GetCheckSumConcurrently(path); + Assert.That(hash1, Is.EqualTo(hash2)); + } +} diff --git a/Tasks/Test1/Test1.Tests/GlobalUsings.cs b/Tasks/Test1/Test1.Tests/GlobalUsings.cs new file mode 100644 index 0000000..cefced4 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using NUnit.Framework; \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/Test1.Tests.csproj b/Tasks/Test1/Test1.Tests/Test1.Tests.csproj new file mode 100644 index 0000000..3d03597 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/Test1.Tests.csproj @@ -0,0 +1,30 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + + + + Always + + + + diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test1/testFile1 b/Tasks/Test1/Test1.Tests/TestFiles/Test1/testFile1 new file mode 100644 index 0000000..12d2fca --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test1/testFile1 @@ -0,0 +1,3 @@ +yvuyvuyvyuyyyuvyuvyuuyvyvyvuyvuyvyuyyyuvyuvyuuyvyvyvuyvuyvyuyyyuvyu +vyuuyvyvyvuyvuyvyuyyyuvyuvyuuyvyvyvuyvuyvyuyyyuvyuvyuuyvyvyvuyvuyvyuyyy +uvyuvyuuyvyvyvuyvuyvyuyyyuvyuvyuuyvyvyvuyvuyvyuyyyuvyuvyuuyvyv \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile1 b/Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile1 new file mode 100644 index 0000000..844ac40 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile1 @@ -0,0 +1,3 @@ +qqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwq +qqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwq +qqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwqqqqqqqqqwqwqwq \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile2 b/Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile2 new file mode 100644 index 0000000..cddf275 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test2/testFile2 @@ -0,0 +1,4 @@ +qqqqqqqqwqwqwq2131313131 +qqqqqqqqwqwqwq2131313131 +qqqqqqqqwqwqwq2131313131 +qqqqqqqqwqwqwq2131313131 \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test3/testFirectory1/testFile1 b/Tasks/Test1/Test1.Tests/TestFiles/Test3/testFirectory1/testFile1 new file mode 100644 index 0000000..aa77590 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test3/testFirectory1/testFile1 @@ -0,0 +1 @@ +90090090302131312900900903021313129009009030213131290090090302131312 \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory1/testFile1 b/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory1/testFile1 new file mode 100644 index 0000000..e23cce4 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory1/testFile1 @@ -0,0 +1 @@ +11111111111111222222222222aaaaaaaaaaa \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile2 b/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile2 new file mode 100644 index 0000000..ad779cf --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile2 @@ -0,0 +1 @@ +11111111111111222222222222aaaaaaaaaaa11111111111111222222222222aaaaaaaaaaa1211 \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile3 b/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile3 new file mode 100644 index 0000000..caac8a4 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test4/testDirectory2/testFile3 @@ -0,0 +1 @@ +00000000111111111111111111111111111112222222222222211111111111111222222222222aaaaaaaaaaa \ No newline at end of file diff --git a/Tasks/Test1/Test1.sln b/Tasks/Test1/Test1.sln index 25626cf..a4c8db6 100644 --- a/Tasks/Test1/Test1.sln +++ b/Tasks/Test1/Test1.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test1", "Test1\Test1.csproj", "{E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test1.Tests", "Test1.Tests\Test1.Tests.csproj", "{F9AFFFD2-F330-491C-8C88-A114CE9EBC22}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,13 @@ Global {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Debug|Any CPU.Build.0 = Debug|Any CPU {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Release|Any CPU.ActiveCfg = Release|Any CPU {E17B3681-8DCA-4F5D-BCF6-B941B2A3C896}.Release|Any CPU.Build.0 = Release|Any CPU + {7F25481E-3621-4545-95FA-ACF6A3C42F70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F25481E-3621-4545-95FA-ACF6A3C42F70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F25481E-3621-4545-95FA-ACF6A3C42F70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F25481E-3621-4545-95FA-ACF6A3C42F70}.Release|Any CPU.Build.0 = Release|Any CPU + {F9AFFFD2-F330-491C-8C88-A114CE9EBC22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9AFFFD2-F330-491C-8C88-A114CE9EBC22}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9AFFFD2-F330-491C-8C88-A114CE9EBC22}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9AFFFD2-F330-491C-8C88-A114CE9EBC22}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Tasks/Test1/Test1/Class1.cs b/Tasks/Test1/Test1/CheckSumUtils.cs similarity index 80% rename from Tasks/Test1/Test1/Class1.cs rename to Tasks/Test1/Test1/CheckSumUtils.cs index b797355..65c1eff 100644 --- a/Tasks/Test1/Test1/Class1.cs +++ b/Tasks/Test1/Test1/CheckSumUtils.cs @@ -7,12 +7,12 @@ using System.Security.Cryptography; using System.Text; -namespace Test1; +namespace CheckSum; /// /// Class for evaluating file chack sum. /// -public static class CheckSumEvaluator +public static class CheckSumUtils { /// /// Evaluate the check sum of given file sequentially. @@ -68,7 +68,10 @@ private static byte[] GetDirectoryCheckSumSequentially(string path) var name = Path.GetFileName(path); var nameHash = MD5.HashData(Encoding.Unicode.GetBytes(name)); result.AddRange(nameHash); - foreach (var entry in Directory.GetFileSystemEntries(path)) + + var entries = Directory.GetFileSystemEntries(path); + Array.Sort(entries); + foreach (var entry in entries) { result.AddRange(GetCheckSumSequentially(entry)); } @@ -86,25 +89,30 @@ private static byte[] GetDirectoryCheckSumConcurrently(string path) { var tasks = new List>(); var name = Path.GetFileName(path); - tasks.Add(Task.Run(() => MD5.HashData(Encoding.Unicode.GetBytes(name)))); - foreach (var entry in Directory.GetFileSystemEntries(path)) + var nameHash = MD5.HashData(Encoding.Unicode.GetBytes(name)); + tasks.Add(Task.Run(() => nameHash)); + + var entries = Directory.GetFileSystemEntries(path); + Array.Sort(entries); + foreach (var entry in entries) { tasks.Add(GetCheckSumConcurrently(entry)); } - int size = 0; + var resultSize = 0; foreach (var task in tasks) { - size += task.Result.Length; + resultSize += task.Result.Length; } - var result = new byte[size]; - for (int taskI = 0; taskI < tasks.Count; ++taskI) + var result = new byte[resultSize]; + var currentIndex = 0; + foreach (var task in tasks) { - var task = tasks[taskI]; for (int i = 0; i < task.Result.Length; ++i) { - result[i] = task.Result[i]; + result[currentIndex] = task.Result[i]; + ++currentIndex; } } From e09ca4ff071a31ddc8747d8b81fd424b3899e4f0 Mon Sep 17 00:00:00 2001 From: bygu4 Date: Thu, 31 Oct 2024 18:52:54 +0300 Subject: [PATCH 3/6] add Main, update tests --- Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs | 13 +++++- Tasks/Test1/Test1.Tests/GlobalUsings.cs | 8 +++- Tasks/Test1/Test1/Program.cs | 49 ++++++++++++++++++++ Tasks/Test1/Test1/Test1.csproj | 1 + 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 Tasks/Test1/Test1/Program.cs diff --git a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs index 25e886c..cbff780 100644 --- a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs +++ b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs @@ -6,7 +6,7 @@ namespace CheckSum.Tests; -public class CheckSumUtilsTest +public static class CheckSumUtilsTest { private const string TestFilesPath = "TestFiles/"; @@ -19,10 +19,19 @@ public static IEnumerable TestCases() } [TestCaseSource(nameof(TestCases))] - public async Task TestCheckSumEvaluation(string path) + public static async Task TestCheckSumEvaluation_CheckSumsAreEqual(string path) { var hash1 = CheckSumUtils.GetCheckSumSequentially(path); var hash2 = await CheckSumUtils.GetCheckSumConcurrently(path); Assert.That(hash1, Is.EqualTo(hash2)); } + + [Test] + public static void TestCheckSumEvaluation_Unexistent_ThrowException() + { + Assert.Throws( + () => CheckSumUtils.GetCheckSumSequentially("agsgdffdghgf")); + Assert.ThrowsAsync( + async () => await CheckSumUtils.GetCheckSumConcurrently("agsgdffdghgf")); + } } diff --git a/Tasks/Test1/Test1.Tests/GlobalUsings.cs b/Tasks/Test1/Test1.Tests/GlobalUsings.cs index cefced4..b2bec5b 100644 --- a/Tasks/Test1/Test1.Tests/GlobalUsings.cs +++ b/Tasks/Test1/Test1.Tests/GlobalUsings.cs @@ -1 +1,7 @@ -global using NUnit.Framework; \ No newline at end of file +// Copyright (c) 2024 +// +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +global using NUnit.Framework; diff --git a/Tasks/Test1/Test1/Program.cs b/Tasks/Test1/Test1/Program.cs new file mode 100644 index 0000000..5a19955 --- /dev/null +++ b/Tasks/Test1/Test1/Program.cs @@ -0,0 +1,49 @@ +// Copyright (c) 2024 +// +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +namespace CheckSum; + +using System.Diagnostics; + +/// +/// Program that compares the time of sequential an +/// concurrent check sum evaluation variations. +/// +public static class Program +{ + /// + /// Main entry point of the program. + /// + /// First argument is the path of + /// the file to evaluate the check sum of. + public static void Main(string[] args) + { + if (args.Length != 1) + { + throw new ArgumentException("Invalid arguments.\nExpected: Path of the file"); + } + + var path = args[0]; + var stopWatch = new Stopwatch(); + + try + { + stopWatch.Restart(); + CheckSumUtils.GetCheckSumSequentially(path); + stopWatch.Stop(); + Console.WriteLine($"Time of the sequential evaluation: {stopWatch.Elapsed}"); + + stopWatch.Restart(); + CheckSumUtils.GetCheckSumConcurrently(path).Wait(); + stopWatch.Stop(); + Console.WriteLine($"Time of the concurrent evaluation: {stopWatch.Elapsed}"); + } + catch (FileNotFoundException e) + { + Console.WriteLine($"Error: {e.Message}"); + } + } +} diff --git a/Tasks/Test1/Test1/Test1.csproj b/Tasks/Test1/Test1/Test1.csproj index 3652ffa..91c3e1e 100644 --- a/Tasks/Test1/Test1/Test1.csproj +++ b/Tasks/Test1/Test1/Test1.csproj @@ -1,5 +1,6 @@ + Exe net8.0 enable enable From 53541e30df7a97406c7b5c094a5f75e44c3b9a88 Mon Sep 17 00:00:00 2001 From: bygu4 Date: Thu, 31 Oct 2024 18:54:50 +0300 Subject: [PATCH 4/6] correct typos --- Tasks/Test1/Test1/CheckSumUtils.cs | 2 +- Tasks/Test1/Test1/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/Test1/Test1/CheckSumUtils.cs b/Tasks/Test1/Test1/CheckSumUtils.cs index 65c1eff..14fc7a3 100644 --- a/Tasks/Test1/Test1/CheckSumUtils.cs +++ b/Tasks/Test1/Test1/CheckSumUtils.cs @@ -10,7 +10,7 @@ namespace CheckSum; /// -/// Class for evaluating file chack sum. +/// Class for evaluating file check sums. /// public static class CheckSumUtils { diff --git a/Tasks/Test1/Test1/Program.cs b/Tasks/Test1/Test1/Program.cs index 5a19955..8ddc6e2 100644 --- a/Tasks/Test1/Test1/Program.cs +++ b/Tasks/Test1/Test1/Program.cs @@ -9,7 +9,7 @@ namespace CheckSum; using System.Diagnostics; /// -/// Program that compares the time of sequential an +/// Program that compares the time of sequential and /// concurrent check sum evaluation variations. /// public static class Program From 18819f393e0b32157be4586bd9106c2aeb884ddc Mon Sep 17 00:00:00 2001 From: bygu4 Date: Thu, 31 Oct 2024 19:19:11 +0300 Subject: [PATCH 5/6] update tests --- Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs | 8 ++++---- Tasks/Test1/Test1.Tests/TestFiles/Test5 | 3 +++ Tasks/Test1/Test1.Tests/TestFiles/Test6 | 0 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test5 create mode 100644 Tasks/Test1/Test1.Tests/TestFiles/Test6 diff --git a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs index cbff780..cbea460 100644 --- a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs +++ b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs @@ -12,14 +12,14 @@ public static class CheckSumUtilsTest public static IEnumerable TestCases() { - foreach (var testDirectory in Directory.GetDirectories(TestFilesPath)) + foreach (var testFile in Directory.GetFileSystemEntries(TestFilesPath)) { - yield return new TestCaseData(testDirectory); + yield return new TestCaseData(testFile); } } [TestCaseSource(nameof(TestCases))] - public static async Task TestCheckSumEvaluation_CheckSumsAreEqual(string path) + public static async Task TestCheckSumEvaluation_CorrectCases_CheckSumsAreEqual(string path) { var hash1 = CheckSumUtils.GetCheckSumSequentially(path); var hash2 = await CheckSumUtils.GetCheckSumConcurrently(path); @@ -27,7 +27,7 @@ public static async Task TestCheckSumEvaluation_CheckSumsAreEqual(string path) } [Test] - public static void TestCheckSumEvaluation_Unexistent_ThrowException() + public static void TestCheckSumEvaluation_UnexistentFile_ThrowException() { Assert.Throws( () => CheckSumUtils.GetCheckSumSequentially("agsgdffdghgf")); diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test5 b/Tasks/Test1/Test1.Tests/TestFiles/Test5 new file mode 100644 index 0000000..69395d1 --- /dev/null +++ b/Tasks/Test1/Test1.Tests/TestFiles/Test5 @@ -0,0 +1,3 @@ +fasgagasasgassg049203209-05034958034 +32313 +321312 \ No newline at end of file diff --git a/Tasks/Test1/Test1.Tests/TestFiles/Test6 b/Tasks/Test1/Test1.Tests/TestFiles/Test6 new file mode 100644 index 0000000..e69de29 From addb19833437a5728dc53ab18ba7953560df8b16 Mon Sep 17 00:00:00 2001 From: bygu4 Date: Sat, 12 Apr 2025 21:43:51 +0300 Subject: [PATCH 6/6] update headers --- Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs | 2 +- Tasks/Test1/Test1.Tests/GlobalUsings.cs | 2 +- Tasks/Test1/Test1.Tests/Test1.Tests.csproj | 2 +- Tasks/Test1/Test1/CheckSumUtils.cs | 2 +- Tasks/Test1/Test1/Program.cs | 2 +- Tasks/Test1/Test1/Test1.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs index cbea460..094dce5 100644 --- a/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs +++ b/Tasks/Test1/Test1.Tests/CheckSumUtilsTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2024 +// Copyright (c) Alexander Bugaev 2024 // // Use of this source code is governed by an MIT license // that can be found in the LICENSE file or at diff --git a/Tasks/Test1/Test1.Tests/GlobalUsings.cs b/Tasks/Test1/Test1.Tests/GlobalUsings.cs index b2bec5b..977475e 100644 --- a/Tasks/Test1/Test1.Tests/GlobalUsings.cs +++ b/Tasks/Test1/Test1.Tests/GlobalUsings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2024 +// Copyright (c) Alexander Bugaev 2024 // // Use of this source code is governed by an MIT license // that can be found in the LICENSE file or at diff --git a/Tasks/Test1/Test1.Tests/Test1.Tests.csproj b/Tasks/Test1/Test1.Tests/Test1.Tests.csproj index 3d03597..cf018c1 100644 --- a/Tasks/Test1/Test1.Tests/Test1.Tests.csproj +++ b/Tasks/Test1/Test1.Tests/Test1.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable diff --git a/Tasks/Test1/Test1/CheckSumUtils.cs b/Tasks/Test1/Test1/CheckSumUtils.cs index 14fc7a3..e71c7e9 100644 --- a/Tasks/Test1/Test1/CheckSumUtils.cs +++ b/Tasks/Test1/Test1/CheckSumUtils.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2024 +// Copyright (c) Alexander Bugaev 2024 // // Use of this source code is governed by an MIT license // that can be found in the LICENSE file or at diff --git a/Tasks/Test1/Test1/Program.cs b/Tasks/Test1/Test1/Program.cs index 8ddc6e2..e4eb63a 100644 --- a/Tasks/Test1/Test1/Program.cs +++ b/Tasks/Test1/Test1/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2024 +// Copyright (c) Alexander Bugaev 2024 // // Use of this source code is governed by an MIT license // that can be found in the LICENSE file or at diff --git a/Tasks/Test1/Test1/Test1.csproj b/Tasks/Test1/Test1/Test1.csproj index 91c3e1e..a719fbf 100644 --- a/Tasks/Test1/Test1/Test1.csproj +++ b/Tasks/Test1/Test1/Test1.csproj @@ -1,7 +1,7 @@ Exe - net8.0 + net9.0 enable enable