From 45abc1a99e7f482c77081836d13f416566512e34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:41:09 +0000 Subject: [PATCH 1/5] Bump nunit from 3.13.3 to 4.0.1 Bumps [nunit](https://github.com/nunit/nunit) from 3.13.3 to 4.0.1. - [Release notes](https://github.com/nunit/nunit/releases) - [Changelog](https://github.com/nunit/nunit/blob/master/CHANGES.md) - [Commits](https://github.com/nunit/nunit/compare/v3.13.3...v4.0.1) --- updated-dependencies: - dependency-name: nunit dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj b/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj index 1445c7c..fb4ad46 100644 --- a/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj +++ b/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj @@ -21,7 +21,7 @@ runtime; build; native; contentfiles; analyzers - + From cb9b44b125011e7fdd8db9ffeffbc15469ea3fe8 Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Fri, 21 Jun 2024 11:55:34 +0200 Subject: [PATCH 2/5] some nunit 4 adjustments --- .../ApiDirectoryBuilderTests.cs | 76 +++++++++---------- .../ApiRequestTests.cs | 24 +++--- tests/Webserver.API.UnitTests/ModelTests.cs | 6 +- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs b/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs index 66c0f7a..f8c6fb6 100644 --- a/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs +++ b/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs @@ -75,12 +75,12 @@ public void T004_EmptyDirectory_Built() var builder = new ApiDirectoryBuilder(localTmpDirectory, new ApiFileResourceBuilder(), false); var parseConfig = new ApiDirectoryBuilderConfiguration() { }; var res = builder.Build(parseConfig); - Assert.AreEqual(localTmpDirectory, res.PathToLocalDirectory); - Assert.AreEqual(0, res.Resources.Count); - Assert.AreEqual(ApiFileResourceState.Active, res.State); + Assert.That(res.PathToLocalDirectory, Is.EqualTo(localTmpDirectory)); + Assert.That(res.Resources.Count, Is.EqualTo(0)); + Assert.That(res.State, Is.EqualTo(ApiFileResourceState.Active)); var dirInf = new DirectoryInfo(localTmpDirectory); - Assert.AreEqual(dirInf.LastWriteTime, res.Last_Modified); - Assert.AreEqual(dirInf.Name, res.Name); + Assert.That(res.Last_Modified, Is.EqualTo(dirInf.LastWriteTime)); + Assert.That(res.Name, Is.EqualTo(dirInf.Name)); Assert.IsNull(res.Size); } finally @@ -104,15 +104,15 @@ public void T005_DirectoryWithFile_Built() var builder = new ApiDirectoryBuilder(localTmpDirectory, new ApiFileResourceBuilder(), false); var parseConfig = new ApiDirectoryBuilderConfiguration() { }; var res = builder.Build(parseConfig); - Assert.AreEqual(1, res.Resources.Count); + Assert.That(res.Resources.Count, Is.EqualTo(1)); Assert.IsNull(res.Size); var firstRes = res.Resources.First(); - Assert.AreEqual(ApiFileResourceType.File, firstRes.Type); - Assert.AreEqual(ApiFileResourceState.Active, firstRes.State); + Assert.That(firstRes.Type, Is.EqualTo(ApiFileResourceType.File)); + Assert.That(firstRes.State, Is.EqualTo(ApiFileResourceState.Active)); var fileInfo = new FileInfo(filePath); - Assert.AreEqual(fileInfo.Length, firstRes.Size); - Assert.AreEqual(fileInfo.LastWriteTime, firstRes.Last_Modified); - Assert.AreEqual(localTmpDirectory, firstRes.PathToLocalDirectory); + Assert.That(firstRes.Size, Is.EqualTo(fileInfo.Length)); + Assert.That(firstRes.Last_Modified, Is.EqualTo(fileInfo.LastWriteTime)); + Assert.That(firstRes.PathToLocalDirectory, Is.EqualTo(localTmpDirectory)); } finally { @@ -132,14 +132,14 @@ public void T006_DirectoryWithDir_Built() var builder = new ApiDirectoryBuilder(localTmpDirectory, new ApiFileResourceBuilder(), false); var parseConfig = new ApiDirectoryBuilderConfiguration() { }; var res = builder.Build(parseConfig); - Assert.AreEqual(1, res.Resources.Count); + Assert.That(res.Resources.Count, Is.EqualTo(1)); Assert.IsNull(res.Size); var firstRes = res.Resources.First(); - Assert.AreEqual(ApiFileResourceType.Dir, firstRes.Type); - Assert.AreEqual(ApiFileResourceState.Active, firstRes.State); + Assert.That(firstRes.Type, Is.EqualTo(ApiFileResourceType.Dir)); + Assert.That(firstRes.State, Is.EqualTo(ApiFileResourceState.Active)); Assert.IsNull(firstRes.Size); - Assert.AreEqual(dirInfo.LastWriteTime, firstRes.Last_Modified); - Assert.AreEqual(dirPath, firstRes.PathToLocalDirectory); + Assert.That(firstRes.Last_Modified, Is.EqualTo(dirInfo.LastWriteTime)); + Assert.That(firstRes.PathToLocalDirectory, Is.EqualTo(dirPath)); } finally { @@ -186,38 +186,38 @@ public void T007_DirectoryWithDirAndFiles_Built() var builder = new ApiDirectoryBuilder(localTmpDirectory, new ApiFileResourceBuilder(), false); var parseConfig = new ApiDirectoryBuilderConfiguration() { }; var res = builder.Build(parseConfig); - Assert.AreEqual(2, res.Resources.Count); + Assert.That(res.Resources.Count, Is.EqualTo(2)); var dirRes = res.Resources.First(el => el.Type == ApiFileResourceType.Dir); var fileRes = res.Resources.First(el => el.Type == ApiFileResourceType.File); - Assert.AreEqual(dirInfo2.Name, dirRes.Name); - Assert.AreEqual(2, dirRes.Resources.Count); - Assert.AreEqual(1, dirRes.Parents.Count); - Assert.AreEqual(dirInfo2.FullName, dirRes.PathToLocalDirectory); + Assert.That(dirRes.Name, Is.EqualTo(dirInfo2.Name)); + Assert.That(dirRes.Resources.Count, Is.EqualTo(2)); + Assert.That(dirRes.Parents.Count, Is.EqualTo(1)); + Assert.That(dirRes.PathToLocalDirectory, Is.EqualTo(dirInfo2.FullName)); - Assert.AreEqual(fileInfo.Name, fileRes.Name); - Assert.AreEqual(filePath, Path.Combine(fileRes.PathToLocalDirectory, fileRes.Name)); - Assert.AreEqual(1, fileRes.Parents.Count); - Assert.AreEqual(0, fileRes.Resources.Count); + Assert.That(fileRes.Name, Is.EqualTo(fileInfo.Name)); + Assert.That(Path.Combine(fileRes.PathToLocalDirectory, fileRes.Name), Is.EqualTo(filePath)); + Assert.That(fileRes.Parents.Count, Is.EqualTo(1)); + Assert.That(fileRes.Resources.Count, Is.EqualTo(0)); var subRes = dirRes.Resources; - Assert.AreEqual(2, subRes.Count); + Assert.That(subRes.Count, Is.EqualTo(2)); var dirRes2 = subRes.First(el => el.Type == ApiFileResourceType.Dir); var fileRes2 = subRes.First(el => el.Type == ApiFileResourceType.File); - Assert.AreEqual(dirInfo3.Name, dirRes2.Name); - Assert.AreEqual(1, dirRes2.Resources.Count); - Assert.AreEqual(2, dirRes2.Parents.Count); - Assert.AreEqual(dirPath3, dirRes2.PathToLocalDirectory); + Assert.That(dirRes2.Name, Is.EqualTo(dirInfo3.Name)); + Assert.That(dirRes2.Resources.Count, Is.EqualTo(1)); + Assert.That(dirRes2.Parents.Count, Is.EqualTo(2)); + Assert.That(dirRes2.PathToLocalDirectory, Is.EqualTo(dirPath3)); - Assert.AreEqual(fileInfo2.Name, fileRes2.Name); - Assert.AreEqual(filePath2, Path.Combine(fileRes2.PathToLocalDirectory, fileRes2.Name)); - Assert.AreEqual(2, fileRes2.Parents.Count); - Assert.AreEqual(0, fileRes2.Resources.Count); + Assert.That(fileRes2.Name, Is.EqualTo(fileInfo2.Name)); + Assert.That(Path.Combine(fileRes2.PathToLocalDirectory, fileRes2.Name), Is.EqualTo(filePath2)); + Assert.That(fileRes2.Parents.Count, Is.EqualTo(2)); + Assert.That(fileRes2.Resources.Count, Is.EqualTo(0)); var fileRes3 = dirRes2.Resources.First(); - Assert.AreEqual(fileInfo3.Name, fileRes3.Name); - Assert.AreEqual(filePath3, Path.Combine(fileRes3.PathToLocalDirectory, fileRes3.Name)); - Assert.AreEqual(0, fileRes3.Resources.Count); - Assert.AreEqual(3, fileRes3.Parents.Count); + Assert.That(fileRes3.Name, Is.EqualTo(fileInfo3.Name)); + Assert.That(Path.Combine(fileRes3.PathToLocalDirectory, fileRes3.Name), Is.EqualTo(filePath3)); + Assert.That(fileRes3.Resources.Count, Is.EqualTo(0)); + Assert.That(fileRes3.Parents.Count, Is.EqualTo(3)); } finally { diff --git a/tests/Webserver.API.UnitTests/ApiRequestTests.cs b/tests/Webserver.API.UnitTests/ApiRequestTests.cs index 441fadc..8e28503 100644 --- a/tests/Webserver.API.UnitTests/ApiRequestTests.cs +++ b/tests/Webserver.API.UnitTests/ApiRequestTests.cs @@ -2550,7 +2550,7 @@ public async Task T037_PlcReadSystemTime_Always_Works() var expectedDate = new DateTime(2022, 03, 01, 17, 2, 4); expectedDate += TimeSpan.FromMilliseconds(238); expectedDate += TimeSpan.FromTicks(2960); - Assert.AreEqual(systemTime.Result.Timestamp, expectedDate); + Assert.That(expectedDate, Is.EqualTo(systemTime.Result.Timestamp)); } /// @@ -2573,8 +2573,8 @@ public async Task T038_01_PlcReadTimeSettings_Rule_Works() var dst = new DaylightSavingsTimeConfiguration(new PlcDate(3, 5, ApiDayOfWeek.Sun, 1, 0), new TimeSpan(0, 60, 0)); var sdt = new StandardTimeConfiguration(new PlcDate(10, 5, ApiDayOfWeek.Sun, 2, 0)); var expectedRule = new DaylightSavingsRule(sdt, dst); - Assert.AreEqual(TimeSpan.Zero, result.Current_offset, "Current offset is not equal to expected value!"); - Assert.AreEqual(expectedRule, result.Rule, "Time setting rule doesn't match!"); + Assert.That(result.Current_offset, Is.EqualTo(TimeSpan.Zero), "Current offset is not equal to expected value!"); + Assert.That(result.Rule, Is.EqualTo(expectedRule), "Time setting rule doesn't match!"); } /// @@ -2594,10 +2594,10 @@ public async Task T038_02_PlcReadTimeSettings_NoRule_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var timeSettings = await TestHandler.PlcReadTimeSettingsAsync(); var result = timeSettings.Result; - Assert.AreEqual(TimeSpan.Zero, result.Current_offset); - Assert.AreEqual(TimeSpan.Zero, result.Utc_offset); + Assert.That(result.Current_offset, Is.EqualTo(TimeSpan.Zero)); + Assert.That(result.Utc_offset, Is.EqualTo(TimeSpan.Zero)); var rule = result.Rule; - Assert.AreEqual(null, rule); + Assert.That(rule, Is.EqualTo(null)); } /// @@ -2679,8 +2679,8 @@ public async Task T041_01_FilesBrowse_TestFolder_Works() var result = browsedResult.Result; var expectedRes1 = new ApiFileResource() { Name = "pre3.png", Size = 20511, Type = ApiFileResourceType.File, Last_Modified = new DateTime(637818317050000000) }; var expectedRes2 = new ApiFileResource() { Name = "uploadfromdev.png", Size = 110308, Type = ApiFileResourceType.File, Last_Modified = new DateTime(637818316970000000) }; - Assert.AreEqual(result.Resources[0], expectedRes1); - Assert.AreEqual(result.Resources[1], expectedRes2); + Assert.That(expectedRes1, Is.EqualTo(result.Resources[0])); + Assert.That(expectedRes2, Is.EqualTo(result.Resources[1])); } /// @@ -2818,8 +2818,8 @@ public async Task T048_01_ApiDataLogsBrowse_Works() var result = browsedResult.Result; var expectedRes1 = new ApiFileResource() { Name = "pre3.png", Size = 20511, Type = ApiFileResourceType.File, Last_Modified = new DateTime(637818317050000000) }; var expectedRes2 = new ApiFileResource() { Name = "uploadfromdev.png", Size = 110308, Type = ApiFileResourceType.File, Last_Modified = new DateTime(637818316970000000) }; - Assert.AreEqual(result.Resources[0], expectedRes1); - Assert.AreEqual(result.Resources[1], expectedRes2); + Assert.That(expectedRes1, Is.EqualTo(result.Resources[0])); + Assert.That(expectedRes2, Is.EqualTo(result.Resources[1])); } /// @@ -2927,7 +2927,7 @@ public async Task T053_01_ApiFailsafeReadParameters_CPU_Works() fs.Collective_signature = "BC7C0410"; fs.Remaining_time = new TimeSpan(2, 33, 0); Assert.That(result.Result.Safety_mode); - Assert.AreEqual(ApiFailsafeHardwareType.F_cpu, result.Result.Type); + Assert.That(result.Result.Type, Is.EqualTo(ApiFailsafeHardwareType.F_cpu)); Assert.That(result.Result.Parameters is FailsafeCPU); Assert.That(result.Result.Parameters.Equals(fs)); } @@ -2954,7 +2954,7 @@ public async Task T053_02_ApiFailsafeReadParameters_Module_Works() fs.F_source_address = 321; fs.F_par_crc = "DBB32A1A"; Assert.That(result.Result.Safety_mode); - Assert.AreEqual(ApiFailsafeHardwareType.F_module, result.Result.Type); + Assert.That(result.Result.Type, Is.EqualTo(ApiFailsafeHardwareType.F_module)); Assert.That(result.Result.Parameters is FailsafeModule); Assert.That(result.Result.Parameters.Equals(fs)); } diff --git a/tests/Webserver.API.UnitTests/ModelTests.cs b/tests/Webserver.API.UnitTests/ModelTests.cs index 3f5c2fb..4804a18 100644 --- a/tests/Webserver.API.UnitTests/ModelTests.cs +++ b/tests/Webserver.API.UnitTests/ModelTests.cs @@ -855,7 +855,7 @@ public void ApiSyslog_HashCodeCheck() ApiPlcSyslog not_equal3 = new ApiPlcSyslog() { Count_Lost = 5, Count_Total = 100, Entries = apiSyslog_Entries_other }; Assert.AreEqual(equal1.GetHashCode(), equal1.GetHashCode(), $"equal1.GetHashCode() not equal equal1.GetHashCode()"); Assert.AreEqual(equal1.GetHashCode(), equal2.GetHashCode(), $"equal1.GetHashCode() not equal equal2.GetHashCode()"); - Assert.False(equal1.GetHashCode() == not_equal1.GetHashCode(), $"equal1.GetHashCode() equal not_equal1.GetHashCode()"); + Assert.That(equal1.GetHashCode() == not_equal1.GetHashCode(), $"equal1.GetHashCode() equal not_equal1.GetHashCode()"); Assert.False(equal1.GetHashCode() == not_equal2.GetHashCode(), $"equal1.GetHashCode() equal not_equal2.GetHashCode()"); Assert.False(equal1.GetHashCode() == not_equal3.GetHashCode(), $"equal1.GetHashCode() equal not_equal3.GetHashCode()"); } @@ -865,8 +865,8 @@ public void ApiSyslog_Entry_HashCodeCheck() ApiPlcSyslog_Entry equal1 = new ApiPlcSyslog_Entry() { Raw = "random text" }; ApiPlcSyslog_Entry equal2 = new ApiPlcSyslog_Entry() { Raw = "random text" }; ApiPlcSyslog_Entry not_equal1 = new ApiPlcSyslog_Entry() { Raw = "random txet" }; - Assert.AreEqual(equal1.GetHashCode(), equal1.GetHashCode(), $"equal1.GetHashCode() not equal equal1.GetHashCode()"); - Assert.AreEqual(equal1.GetHashCode(), equal2.GetHashCode(), $"equal1.GetHashCode() not equal equal2.GetHashCode()"); + Assert.That(equal1.GetHashCode(), Is.EqualTo(equal1.GetHashCode()), $"equal1.GetHashCode() not equal equal1.GetHashCode()"); + Assert.That(equal1.GetHashCode(), Is.EqualTo(equal2.GetHashCode()), $"equal1.GetHashCode() not equal equal2.GetHashCode()"); Assert.False(equal1.GetHashCode() == not_equal1.GetHashCode(), $"equal1.GetHashCode() equal not_equal1.GetHashCode()"); } From 44f9a3315230e7819ade0c66fdb3db9c26678605 Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Mon, 21 Oct 2024 18:33:44 +0200 Subject: [PATCH 3/5] adjuist asserts for nunit 4 --- .../ApiDirectoryBuilderTests.cs | 8 +- .../ApiRequestTests.cs | 110 +++++++++--------- tests/Webserver.API.UnitTests/ModelTests.cs | 101 +++++++++------- 3 files changed, 115 insertions(+), 104 deletions(-) diff --git a/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs b/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs index f8c6fb6..6fdc525 100644 --- a/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs +++ b/tests/Webserver.API.UnitTests/ApiDirectoryBuilderTests.cs @@ -81,7 +81,7 @@ public void T004_EmptyDirectory_Built() var dirInf = new DirectoryInfo(localTmpDirectory); Assert.That(res.Last_Modified, Is.EqualTo(dirInf.LastWriteTime)); Assert.That(res.Name, Is.EqualTo(dirInf.Name)); - Assert.IsNull(res.Size); + Assert.That(res.Size, Is.Null); } finally { @@ -105,7 +105,7 @@ public void T005_DirectoryWithFile_Built() var parseConfig = new ApiDirectoryBuilderConfiguration() { }; var res = builder.Build(parseConfig); Assert.That(res.Resources.Count, Is.EqualTo(1)); - Assert.IsNull(res.Size); + Assert.That(res.Size, Is.Null); var firstRes = res.Resources.First(); Assert.That(firstRes.Type, Is.EqualTo(ApiFileResourceType.File)); Assert.That(firstRes.State, Is.EqualTo(ApiFileResourceState.Active)); @@ -133,11 +133,11 @@ public void T006_DirectoryWithDir_Built() var parseConfig = new ApiDirectoryBuilderConfiguration() { }; var res = builder.Build(parseConfig); Assert.That(res.Resources.Count, Is.EqualTo(1)); - Assert.IsNull(res.Size); + Assert.That(res.Size, Is.Null); var firstRes = res.Resources.First(); Assert.That(firstRes.Type, Is.EqualTo(ApiFileResourceType.Dir)); Assert.That(firstRes.State, Is.EqualTo(ApiFileResourceState.Active)); - Assert.IsNull(firstRes.Size); + Assert.That(firstRes.Size, Is.Null); Assert.That(firstRes.Last_Modified, Is.EqualTo(dirInfo.LastWriteTime)); Assert.That(firstRes.PathToLocalDirectory, Is.EqualTo(dirPath)); } diff --git a/tests/Webserver.API.UnitTests/ApiRequestTests.cs b/tests/Webserver.API.UnitTests/ApiRequestTests.cs index 8e28503..7fb2805 100644 --- a/tests/Webserver.API.UnitTests/ApiRequestTests.cs +++ b/tests/Webserver.API.UnitTests/ApiRequestTests.cs @@ -2617,7 +2617,7 @@ public async Task T039_01_PlcCreateBackup_Valid_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var expected = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; var resp = await TestHandler.PlcCreateBackupAsync(); - Assert.IsTrue(resp.Result.ToString() == expected, "Failed"); + Assert.That(resp.Result.ToString() == expected, "Failed"); } /// @@ -2637,7 +2637,7 @@ public async Task T040_01_PlcRestoreBackup_Valid_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var expected = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; var resp = await TestHandler.PlcRestoreBackupAsync(); - Assert.IsTrue(resp.Result.ToString() == expected, "Failed"); + Assert.That(resp.Result.ToString() == expected, "Failed"); } /// @@ -2657,7 +2657,7 @@ public async Task T040_01_PlcRestoreBackup_DHCP_Valid_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var expected = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; var resp = await TestHandler.PlcRestoreBackupAsync(); - Assert.IsTrue(resp.Result.ToString() == expected, "Failed"); + Assert.That(resp.Result.ToString() == expected, "Failed"); } /// @@ -2700,7 +2700,7 @@ public async Task T042_01_ApiFilesDownload_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesDownloadAsync("/"); var expectedResult = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; - Assert.AreEqual(expectedResult, result.Result, "The tickets are not identical."); + Assert.That(result.Result, Is.EqualTo(expectedResult)); } /// @@ -2720,7 +2720,7 @@ public async Task T043_01_ApiFilesCreate_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesCreateAsync("/"); var expectedResult = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; - Assert.AreEqual(expectedResult, result.Result, "The tickets are not identical."); + Assert.That(result.Result, Is.EqualTo(expectedResult), "Tickets for FilesCreate!"); } /// @@ -2739,7 +2739,7 @@ public async Task T044_01_ApiFilesCreateDirectory_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesCreateDirectoryAsync("/Dir/newDir"); - Assert.IsTrue(result.Result, "The result is not true."); + Assert.That(result.Result, "The result is not true."); } /// @@ -2758,7 +2758,7 @@ public async Task T045_01_ApiFilesRename_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesRenameAsync("/Dir/newDir", "/Dir/renamedDir"); - Assert.IsTrue(result.Result, "The result is not true."); + Assert.That(result.Result, "The result is not true."); } /// @@ -2777,7 +2777,7 @@ public async Task T046_01_ApiFilesDelete_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesDeleteAsync("/Dir/newDir"); - Assert.IsTrue(result.Result, "The result is not true."); + Assert.That(result.Result, "The result is not true."); } /// @@ -2796,7 +2796,7 @@ public async Task T047_01_ApiFilesDeleteDirectory_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesDeleteDirectoryAsync("/Dir/newDir"); - Assert.IsTrue(result.Result, "The result is not true."); + Assert.That(result.Result, "The result is not true."); } /// @@ -2839,7 +2839,7 @@ public async Task T049_01_ApiDataLogsDownload_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesDownloadAsync("/"); var expectedResult = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; - Assert.AreEqual(expectedResult, result.Result, "The tickets are not identical."); + Assert.That(result.Result, Is.EqualTo(expectedResult)); } /// @@ -2858,7 +2858,7 @@ public async Task T050_01_ApiDataLogsDelete_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.FilesDeleteAsync("/Dir/newDir"); - Assert.IsTrue(result.Result, "The result is not true."); + Assert.That(result.Result, "The result is not true."); } /// @@ -2878,7 +2878,7 @@ public async Task T051_01_ApiDataLogsDownloadAndClear_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.DatalogsDownloadAndClearAsync("/"); var expectedResult = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; - Assert.AreEqual(expectedResult, result.Result, "The tickets are not identical."); + Assert.That(result.Result, Is.EqualTo(expectedResult)); } /// @@ -2899,11 +2899,11 @@ public async Task T052_ApiSyslogBrowse_Works() var result = (await TestHandler.ApiSyslogBrowseAsync()).Result; Assert.Multiple(() => { - Assert.AreEqual(5, result.Count_Total, "result Count_Total is not the expected value!"); - Assert.AreEqual(1, result.Count_Lost, "result Count_Lost is not the expected value!"); - Assert.AreEqual(2, result.Entries.Count, "result Entries.Count is not the expected value!"); - Assert.AreEqual("I am a syslog, no need to question it!", result.Entries[0].Raw, "result Entries[0].Raw is not the expected value!"); - Assert.AreEqual("I am a syslog, too. But the previous syslog is an impostor!", result.Entries[1].Raw, "result Entries[1].Raw is not the expected value!"); + Assert.That(result.Count_Total, Is.EqualTo(5)); + Assert.That(result.Count_Lost, Is.EqualTo(1)); + Assert.That(result.Entries.Count, Is.EqualTo(2)); + Assert.That(result.Entries[0].Raw, Is.EqualTo("I am a syslog, no need to question it!")); + Assert.That(result.Entries[1].Raw, Is.EqualTo("I am a syslog, too. But the previous syslog is an impostor!"), "Tickets for FilesCreate!"); }); } /// @@ -2989,8 +2989,8 @@ public async Task T054_ApiFailsafeReadRuntimeGroups_Works() withRemaining.Cycle_time_Max = TimeSpan.FromMilliseconds(200); withRemaining.Runtime_current = TimeSpan.FromMilliseconds(50); withRemaining.Runtime_max = TimeSpan.FromMilliseconds(80); - Assert.IsTrue(result.Result.Groups[0].Equals(noRemaining), "The groups don't match!"); - Assert.IsTrue(result.Result.Groups[1].Equals(withRemaining), "The groups don't match!"); + Assert.That(result.Result.Groups[0].Equals(noRemaining), "The groups don't match!"); + Assert.That(result.Result.Groups[1].Equals(withRemaining), "The groups don't match!"); } /// @@ -3009,7 +3009,7 @@ public async Task T055_ApiChangePassword_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.ApiChangePasswordAsync("Admin", "adminpw", "newadminpw"); - Assert.IsTrue(result.Result, "Changing passwords not possible!"); + Assert.That(result.Result, "Changing passwords not possible!"); } /// @@ -3035,7 +3035,7 @@ public async Task T056_ApiGetPasswordPolicy_Works() expectedResult.Max_password_length = 120; expectedResult.Min_digits = 1; expectedResult.Min_special_characters = 0; - Assert.AreEqual(expectedResult, result.Result.Password_policy, "Password policies dont match"); + Assert.That(result.Result.Password_policy, Is.EqualTo(expectedResult), "Tickets for FilesCreate!"); } /// @@ -3058,7 +3058,7 @@ public async Task T057_ApiGetAuthenticationMode_Works() expectedResult.Add(ApiAuthenticationMode.Local); expectedResult.Add(ApiAuthenticationMode.Static); expectedResult.Add(ApiAuthenticationMode.Disabled); - Assert.AreEqual(expectedResult.Count, result.Result.Authentication_modes.Count, "Authentication modes count don't match!"); + Assert.That(result.Result.Authentication_modes.Count, Is.EqualTo(expectedResult.Count)); Assert.That(expectedResult.SequenceEqual(result.Result.Authentication_modes), "Order of authetication modes is different!"); } @@ -3083,7 +3083,7 @@ public async Task T058_ProjectReadLanguages_Works() expectedResult.Add(new CultureInfo("en-GB")); expectedResult.Add(new CultureInfo("es-BR")); expectedResult.Add(new CultureInfo("ne-IN")); - Assert.AreEqual(expectedResult.Count, result.Result.Languages.Select(x => x.Language).Count(), "Languages don't match"); + Assert.That(result.Result.Languages.Select(x => x.Language).Count(), Is.EqualTo(expectedResult.Count)); Assert.That(expectedResult.SequenceEqual(result.Result.Languages.Select(x => x.Language)), "The order of languages are different, or they don't contain the same languages."); } @@ -3103,7 +3103,7 @@ public async Task T059_01_ApiPlcReadModeSelectorState_Standard_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var res = await TestHandler.PlcReadModeSelectorStateAsync(ApiPlcRedundancyId.StandardPLC); - Assert.AreEqual(ApiPlcModeSelectorState.Run, res.Result.Mode_Selector, "Plc Mode Selector state is not in run mode!"); + Assert.That(res.Result.Mode_Selector, Is.EqualTo(ApiPlcModeSelectorState.Run)); } /// @@ -3122,7 +3122,7 @@ public async Task T059_02_ApiPlcReadModeSelectorState_RH_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var res = await TestHandler.PlcReadModeSelectorStateAsync(ApiPlcRedundancyId.RedundancyId_1); - Assert.AreEqual(ApiPlcModeSelectorState.NoSwitch, res.Result.Mode_Selector, "Plc Mode Selector state is not in noswitch mode!"); + Assert.That(res.Result.Mode_Selector, Is.EqualTo(ApiPlcModeSelectorState.NoSwitch)); } /// @@ -3142,7 +3142,7 @@ public async Task T060_ApiModulesDownloadServiceData_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.ModulesDownloadServiceDataAsync(ApiPlcHwId.StandardPLC); var expectedResult = "dlBvEAfpgSVBfwlU7Py5TsVbmRTq"; - Assert.AreEqual(expectedResult, result.Result, "The tickets are not identical."); + Assert.That(result.Result, Is.EqualTo(expectedResult)); } /// @@ -3161,7 +3161,7 @@ public async Task T061_ApiAlarmsAcknowledge_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.AlarmsAcknowledgeAsync("/"); - Assert.AreEqual(true, result.Result, "The response should always contain true, but it doesn't."); + Assert.That(result.Result); } /// /// TestCase for Plc.SetSystemTime @@ -3179,7 +3179,7 @@ public async Task T062_PlcSetSystemTime_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.PlcSetSystemTimeAsync(new DateTime(2010, 10, 10)); - Assert.IsTrue(result.Result, "The time was not set successfully!"); + Assert.That(result.Result, "The time was not set successfully!"); } /// @@ -3204,7 +3204,7 @@ public async Task T063_01_ApiPlcSetTimeSettings_Works() DaylightSavingsRule dsr = new DaylightSavingsRule(sdt, dst); var result = await TestHandler.PlcSetTimeSettingsAsync(offset, dsr); - Assert.IsTrue(result.Result, "Couldn't set time settings!"); + Assert.That(result.Result, "Couldn't set time settings!"); } /// @@ -3226,7 +3226,7 @@ public async Task T063_02_ApiPlcSetTimeSettingsNoRule_Works() var offset = new TimeSpan(8, 0, 0); var result = await TestHandler.PlcSetTimeSettingsAsync(offset); - Assert.IsTrue(result.Result, "Couldn't set time settings!"); + Assert.That(result.Result, "Couldn't set time settings!"); } /// @@ -3267,7 +3267,7 @@ public async Task T065_WebServerSetDefaultPage_Works() client.BaseAddress = new Uri($"https://{Ip.ToString()}"); TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.WebServerSetDefaultPageAsync("index.html"); - Assert.IsTrue(result.Result, "The result is not true."); + Assert.That(result.Result, "The result is not true."); } /// /// TestCase for WebServer.ReadDefaultPage @@ -3286,7 +3286,7 @@ public async Task T066_WebServerReadDefaultPage_Works() TestHandler = new ApiHttpClientRequestHandler(client, ApiRequestFactory, ApiResponseChecker); var result = await TestHandler.WebServerGetReadDefaultPageAsync(); var expectedResult = "/~teszt2/index.html"; - Assert.AreEqual(expectedResult, result.Result.Default_page, "The result is not the expected."); + Assert.That(result.Result.Default_page, Is.EqualTo(expectedResult)); } /// @@ -3307,19 +3307,19 @@ public async Task T067_ApiAlarmsBrowse_Works() var result = (await TestHandler.ApiAlarmsBrowseAsync(new CultureInfo("en-US"))).Result; Assert.Multiple(() => { - Assert.AreEqual(2, result.Entries.Count, "result.Entries.Count"); - Assert.AreEqual("9947888669857743000", result.Entries[0].Id, "result.Entries[0].Id"); - Assert.AreEqual(512, result.Entries[0].Alarm_Number, "result.Entries[0].Alarm_Number"); - Assert.AreEqual(ApiObjectDirectoryStatus.Incoming, result.Entries[0].Status, "result.Entries[0].Status"); - Assert.AreEqual(new DateTime(2012, 1, 1, 1, 1, 42, 47), result.Entries[0].Timestamp, "result.Entries[0].Timestamp"); - Assert.AreEqual(ApiAlarmAcknowledgementState.Not_Acknowledged, result.Entries[0].Acknowledgement.State, "result.Entries[0].Acknowledgement.State"); - Assert.AreEqual("#1, 1", result.Entries[0].Alarm_Text, "result.Entries[0].Alarm_Text"); - Assert.AreEqual("#1, 0", result.Entries[0].Info_Text, "result.Entries[0].Info_Text"); - Assert.AreEqual(false, result.Entries[0].Text_Inconsistent, "result.Entries[0].Text_Inconsistent"); - Assert.AreEqual(new DateTime(2012, 1, 1, 1, 1, 42, 99), result.Last_Modified, "result.Last_Modified"); - Assert.AreEqual(51, result.Count_Current, "result.Count_Current"); - Assert.AreEqual(500, result.Count_Max, "result.Count_Max"); - Assert.AreEqual("en-US", result.Language, "result.Language"); + Assert.That(result.Entries.Count, Is.EqualTo(2)); + Assert.That(result.Entries[0].Id, Is.EqualTo("9947888669857743000")); + Assert.That(result.Entries[0].Alarm_Number, Is.EqualTo(512)); + Assert.That(result.Entries[0].Status, Is.EqualTo(ApiObjectDirectoryStatus.Incoming)); + Assert.That(result.Entries[0].Timestamp, Is.EqualTo(new DateTime(2012, 1, 1, 1, 1, 42, 47))); + Assert.That(result.Entries[0].Acknowledgement.State, Is.EqualTo(ApiAlarmAcknowledgementState.Not_Acknowledged)); + Assert.That(result.Entries[0].Alarm_Text, Is.EqualTo("#1, 1")); + Assert.That(result.Entries[0].Info_Text, Is.EqualTo("#1, 0")); + Assert.That(result.Entries[0].Text_Inconsistent, Is.EqualTo(false)); + Assert.That(result.Last_Modified, Is.EqualTo(new DateTime(2012, 1, 1, 1, 1, 42, 99))); + Assert.That(result.Count_Current, Is.EqualTo(51)); + Assert.That(result.Count_Max, Is.EqualTo(500)); + Assert.That(result.Language, Is.EqualTo("en-US")); }); } @@ -3343,16 +3343,16 @@ public async Task T068_ApiDiagnosticBufferBrowse_Works() expected = expected.AddTicks(5146785); Assert.Multiple(() => { - Assert.AreEqual(2, result.Entries.Count, "result.Entries.Count"); - Assert.AreEqual(ApiObjectDirectoryStatus.Outgoing, result.Entries[0].Status, "result.Entries[0].Status"); - Assert.AreEqual("Boot up - CPU changes from OFF to STOP (initialization) mode", result.Entries[0].Short_Text, "result.Entries[0].Short_Text"); - Assert.AreEqual("LONG TEXT", result.Entries[1].Long_Text, "result.Entries[1].Long_Text"); - Assert.AreEqual(3, result.Entries[1].Event.Textlist_Id, "result.Entries[1].Event.Textlist_Id"); - Assert.AreEqual(26315, result.Entries[1].Event.Text_Id, "result.Entries[1].Event.Text_Id"); - Assert.AreEqual(expected, result.Last_Modified, "result.Last_Modified"); - Assert.AreEqual(1234, result.Count_Current, "result.Count_Current"); - Assert.AreEqual(3200, result.Count_Max, "result.Count_Max"); - Assert.AreEqual("en-US", result.Language, "result.Language"); + Assert.That(result.Entries.Count, Is.EqualTo(2)); + Assert.That(result.Entries[0].Status, Is.EqualTo(ApiObjectDirectoryStatus.Outgoing)); + Assert.That(result.Entries[0].Short_Text, Is.EqualTo("Boot up - CPU changes from OFF to STOP (initialization) mode")); + Assert.That(result.Entries[1].Long_Text, Is.EqualTo("LONG TEXT")); + Assert.That(result.Entries[1].Event.Textlist_Id, Is.EqualTo(3)); + Assert.That(result.Entries[1].Event.Text_Id, Is.EqualTo(26315)); + Assert.That(result.Last_Modified, Is.EqualTo(expected)); + Assert.That(result.Count_Current, Is.EqualTo(1234)); + Assert.That(result.Count_Max, Is.EqualTo(3200)); + Assert.That(result.Language, Is.EqualTo("en-US")); }); } } diff --git a/tests/Webserver.API.UnitTests/ModelTests.cs b/tests/Webserver.API.UnitTests/ModelTests.cs index 4804a18..f692411 100644 --- a/tests/Webserver.API.UnitTests/ModelTests.cs +++ b/tests/Webserver.API.UnitTests/ModelTests.cs @@ -765,11 +765,11 @@ public void PlcDate_EqualsCheck() var equalsPD2 = new PlcDate(11, 5, ApiDayOfWeek.Sun, 2, 24); var notEqualsPD1 = new PlcDate(12, 5, ApiDayOfWeek.Sun, 2, 24); - Assert.IsTrue(equalsPD1.Equals(equalsPD2)); - Assert.IsTrue(equalsPD2.Equals(equalsPD1)); + Assert.That(equalsPD1.Equals(equalsPD2)); + Assert.That(equalsPD2.Equals(equalsPD1)); - Assert.IsFalse(equalsPD1.Equals(notEqualsPD1)); - Assert.IsFalse(equalsPD2.Equals(notEqualsPD1)); + Assert.That(notEqualsPD1, Is.Not.EqualTo(equalsPD1)); + Assert.That(notEqualsPD1, Is.Not.EqualTo(equalsPD2)); } [Test] @@ -793,11 +793,11 @@ public void DaylightSavingTimeConfiguration_EqualsCheck() var notequalsDST1 = new DaylightSavingsTimeConfiguration(notEqualsPD2, TimeSpan.FromMinutes(60)); var notequalsDST2 = new DaylightSavingsTimeConfiguration(equalsPD1, TimeSpan.FromMinutes(120)); - Assert.IsTrue(equalsDST1.Equals(equalsDST2)); - Assert.IsTrue(equalsDST2.Equals(equalsDST1)); + Assert.That(equalsDST1.Equals(equalsDST2)); + Assert.That(equalsDST2.Equals(equalsDST1)); - Assert.IsFalse(equalsDST1.Equals(notequalsDST1)); - Assert.IsFalse(equalsDST2.Equals(notequalsDST2)); + Assert.That(notequalsDST1, Is.Not.EqualTo(equalsDST1)); + Assert.That(notequalsDST2, Is.Not.EqualTo(equalsDST2)); } [Test] @@ -811,10 +811,10 @@ public void StandardTimeConfiguration_EqualsCheck() var equalsSTD2 = new StandardTimeConfiguration(equalsPD2); var notequalsSTD1 = new StandardTimeConfiguration(notEqualsPD2); - Assert.IsTrue(equalsSTD1.Equals(equalsSTD2)); - Assert.IsTrue(equalsSTD2.Equals(equalsSTD1)); + Assert.That(equalsSTD1.Equals(equalsSTD2)); + Assert.That(equalsSTD2.Equals(equalsSTD1)); - Assert.IsFalse(equalsSTD1.Equals(notequalsSTD1)); + Assert.That(notequalsSTD1, Is.Not.EqualTo(equalsSTD1)); } [Test] @@ -827,21 +827,24 @@ public void ApiSyslog_EqualsCheck() ApiPlcSyslog not_equal1 = new ApiPlcSyslog() { Count_Lost = 4, Count_Total = 100, Entries = apiSyslog_Entries }; ApiPlcSyslog not_equal2 = new ApiPlcSyslog() { Count_Lost = 5, Count_Total = 99, Entries = apiSyslog_Entries }; ApiPlcSyslog not_equal3 = new ApiPlcSyslog() { Count_Lost = 5, Count_Total = 100, Entries = apiSyslog_Entries_other }; - Assert.True(equal1.Equals(equal2), $"{equal1.ToString()} \nnot equal\n{equal2.ToString()}"); - Assert.True(equal2.Equals(equal1), $"{equal2.ToString()} \nnot equal\n{equal1.ToString()}"); - Assert.False(equal1.Equals(not_equal1), $"{equal1.ToString()} \nequal\n{not_equal1.ToString()}"); - Assert.False(equal1.Equals(not_equal2), $"{equal1.ToString()} \nequal\n{not_equal2.ToString()}"); - Assert.False(equal1.Equals(not_equal3), $"{equal1.ToString()} \nequal\n{not_equal3.ToString()}"); + Assert.That(equal1.Equals(equal2), $"{equal1.ToString()} \nnot equal\n{equal2.ToString()}"); + Assert.That(equal2.Equals(equal1), $"{equal2.ToString()} \nnot equal\n{equal1.ToString()}"); + + Assert.That(equal1, Is.Not.EqualTo(not_equal1)); + Assert.That(equal1, Is.Not.EqualTo(not_equal2)); + Assert.That(equal1, Is.Not.EqualTo(not_equal3)); } + [Test] public void ApiSyslog_Entry_EqualsCheck() { ApiPlcSyslog_Entry equal1 = new ApiPlcSyslog_Entry() { Raw = "random text" }; ApiPlcSyslog_Entry equal2 = new ApiPlcSyslog_Entry() { Raw = "random text" }; ApiPlcSyslog_Entry not_equal1 = new ApiPlcSyslog_Entry() { Raw = "random txet" }; - Assert.True(equal1.Equals(equal2), $"{equal1.ToString()} \nnot equal\n{equal2.ToString()}"); - Assert.True(equal2.Equals(equal1), $"{equal2.ToString()} \nnot equal\n{equal1.ToString()}"); - Assert.False(equal1.Equals(not_equal1), $"{equal1.ToString()} \nequal\n{not_equal1.ToString()}"); + Assert.That(equal1.Equals(equal2), $"{equal1.ToString()} \nnot equal\n{equal2.ToString()}"); + Assert.That(equal2.Equals(equal1), $"{equal2.ToString()} \nnot equal\n{equal1.ToString()}"); + + Assert.That(equal1, Is.Not.EqualTo(not_equal1)); } [Test] public void ApiSyslog_HashCodeCheck() @@ -853,11 +856,12 @@ public void ApiSyslog_HashCodeCheck() ApiPlcSyslog not_equal1 = new ApiPlcSyslog() { Count_Lost = 4, Count_Total = 100, Entries = apiSyslog_Entries }; ApiPlcSyslog not_equal2 = new ApiPlcSyslog() { Count_Lost = 5, Count_Total = 101, Entries = apiSyslog_Entries }; ApiPlcSyslog not_equal3 = new ApiPlcSyslog() { Count_Lost = 5, Count_Total = 100, Entries = apiSyslog_Entries_other }; - Assert.AreEqual(equal1.GetHashCode(), equal1.GetHashCode(), $"equal1.GetHashCode() not equal equal1.GetHashCode()"); - Assert.AreEqual(equal1.GetHashCode(), equal2.GetHashCode(), $"equal1.GetHashCode() not equal equal2.GetHashCode()"); - Assert.That(equal1.GetHashCode() == not_equal1.GetHashCode(), $"equal1.GetHashCode() equal not_equal1.GetHashCode()"); - Assert.False(equal1.GetHashCode() == not_equal2.GetHashCode(), $"equal1.GetHashCode() equal not_equal2.GetHashCode()"); - Assert.False(equal1.GetHashCode() == not_equal3.GetHashCode(), $"equal1.GetHashCode() equal not_equal3.GetHashCode()"); + Assert.That(equal1.GetHashCode(), Is.EqualTo(equal1.GetHashCode()), "GetHashcode was not equal altough it should be"); + Assert.That(equal1.GetHashCode(), Is.EqualTo(equal2.GetHashCode()), "GetHashcode was not equal altough it should be"); + + Assert.That(equal1.GetHashCode(), Is.Not.EqualTo(not_equal1.GetHashCode()), "GetHashcode was equal altough it should not be"); + Assert.That(equal1.GetHashCode(), Is.Not.EqualTo(not_equal2.GetHashCode()), "GetHashcode was equal altough it should not be"); + Assert.That(equal1.GetHashCode(), Is.Not.EqualTo(not_equal3.GetHashCode()), "GetHashcode was equal altough it should not be"); } [Test] public void ApiSyslog_Entry_HashCodeCheck() @@ -867,7 +871,8 @@ public void ApiSyslog_Entry_HashCodeCheck() ApiPlcSyslog_Entry not_equal1 = new ApiPlcSyslog_Entry() { Raw = "random txet" }; Assert.That(equal1.GetHashCode(), Is.EqualTo(equal1.GetHashCode()), $"equal1.GetHashCode() not equal equal1.GetHashCode()"); Assert.That(equal1.GetHashCode(), Is.EqualTo(equal2.GetHashCode()), $"equal1.GetHashCode() not equal equal2.GetHashCode()"); - Assert.False(equal1.GetHashCode() == not_equal1.GetHashCode(), $"equal1.GetHashCode() equal not_equal1.GetHashCode()"); + + Assert.That(equal1.GetHashCode(), Is.Not.EqualTo(not_equal1.GetHashCode()), "GetHashcode was equal altough it should not be"); } [Test] @@ -876,9 +881,10 @@ public void ApiAlarms_EqualsCheck() ApiAlarms equal1 = new ApiAlarms() { Count_Current = 10, Count_Max = 1000, Language = "en-US", Last_Modified = new DateTime(2023, 6, 15, 10, 33, 24, 123) }; ApiAlarms equal2 = new ApiAlarms() { Count_Current = 10, Count_Max = 1000, Language = "en-US", Last_Modified = new DateTime(2023, 6, 15, 10, 33, 24, 123) }; ApiAlarms not_equal = new ApiAlarms() { Count_Current = 11, Count_Max = 1000, Language = "en-US", Last_Modified = new DateTime(2023, 6, 15, 10, 33, 24, 123) }; - Assert.True(equal1.Equals(equal2), $"{equal1.ToString()} not equal\n{equal2.ToString()}"); - Assert.True(equal2.Equals(equal1), $"{equal2.ToString()} not equal\n{equal1.ToString()}"); - Assert.False(equal1.Equals(not_equal), $"{equal1.ToString()} equal\n{equal2.ToString()}"); + Assert.That(equal1.Equals(equal2), $"{equal1.ToString()} not equal\n{equal2.ToString()}"); + Assert.That(equal2.Equals(equal1), $"{equal2.ToString()} not equal\n{equal1.ToString()}"); + + Assert.That(equal1, Is.Not.EqualTo(not_equal), "was equal altough it should not be"); } [Test] @@ -920,9 +926,9 @@ public void ApiAlarms_Entry_EqualsCheck() Info_Text = "word", Text_Inconsistent = false }; - Assert.True(equal1.Equals(equal2), $"{equal1.ToString()} not equal\n{equal2.ToString()}"); - Assert.True(equal2.Equals(equal1), $"{equal2.ToString()} not equal\n{equal1.ToString()}"); - Assert.False(equal1.Equals(not_equal), $"{equal1.ToString()} equal\n{equal2.ToString()}"); + Assert.That(equal1.Equals(equal2), $"{equal1.ToString()} not equal\n{equal2.ToString()}"); + Assert.That(equal2.Equals(equal1), $"{equal2.ToString()} not equal\n{equal1.ToString()}"); + Assert.That(equal1, Is.Not.EqualTo(not_equal)); } [Test] @@ -931,9 +937,10 @@ public void ApiAlarms_EntryAcknowledgement_EqualsCheck() ApiAlarms_EntryAcknowledgement equal1 = new ApiAlarms_EntryAcknowledgement() { State = ApiAlarmAcknowledgementState.Not_Acknowledged }; ApiAlarms_EntryAcknowledgement equal2 = new ApiAlarms_EntryAcknowledgement() { State = ApiAlarmAcknowledgementState.Not_Acknowledged }; ApiAlarms_EntryAcknowledgement not_equal = new ApiAlarms_EntryAcknowledgement() { State = ApiAlarmAcknowledgementState.Acknowledged, Timestamp = new DateTime(2023, 6, 15, 10, 33, 24, 123) }; - Assert.True(equal1.Equals(equal2), $"{equal1.ToString()} \nnot equal\n{equal2.ToString()}"); - Assert.True(equal2.Equals(equal1), $"{equal2.ToString()} \nnot equal\n{equal1.ToString()}"); - Assert.False(equal1.Equals(not_equal), $"{equal1.ToString()} \nequal\n{equal2.ToString()}"); + Assert.That(equal1.Equals(equal2), $"{equal1.ToString()} \nnot equal\n{equal2.ToString()}"); + Assert.That(equal2.Equals(equal1), $"{equal2.ToString()} \nnot equal\n{equal1.ToString()}"); + + Assert.That(equal1, Is.Not.EqualTo(not_equal)); } [Test] @@ -947,10 +954,12 @@ public void ApiDiagnosticBuffer_EqualsCheck() ApiDiagnosticBuffer not_equals4 = new ApiDiagnosticBuffer() { Count_Current = 10, Count_Max = 2400, Language = "en-US", Last_Modified = new DateTime(2021, 6, 15, 10, 33, 24, 123) }; Assert.That(equals1.Equals(equals2), $"{equals1.ToString()} not equal to\n {equals2.ToString()}"); Assert.That(equals2.Equals(equals1), $"{equals2.ToString()} not equal to\n {equals1.ToString()}"); - Assert.False(equals1.Equals(not_equals1), $"{equals1.ToString()} equal to\n {not_equals1.ToString()}"); - Assert.False(equals1.Equals(not_equals2), $"{equals1.ToString()} equal to\n {not_equals2.ToString()}"); - Assert.False(equals1.Equals(not_equals3), $"{equals1.ToString()} equal to\n {not_equals3.ToString()}"); - Assert.False(equals1.Equals(not_equals4), $"{equals1.ToString()} equal to\n {not_equals4.ToString()}"); + + + Assert.That(equals1, Is.Not.EqualTo(not_equals1)); + Assert.That(equals1, Is.Not.EqualTo(not_equals2)); + Assert.That(equals1, Is.Not.EqualTo(not_equals3)); + Assert.That(equals1, Is.Not.EqualTo(not_equals4)); } [Test] public void ApiDiagnosticBuffer_Entry_EqualsCheck() @@ -1020,11 +1029,12 @@ public void ApiDiagnosticBuffer_Entry_EqualsCheck() }; Assert.That(equals1.Equals(equals2), $"{equals1.ToString()} not equal to\n {equals2.ToString()}"); Assert.That(equals2.Equals(equals1), $"{equals2.ToString()} not equal to\n {equals1.ToString()}"); - Assert.False(equals1.Equals(not_equals1), $"{equals1.ToString()} equal to\n {not_equals1.ToString()}"); - Assert.False(equals1.Equals(not_equals2), $"{equals1.ToString()} equal to\n {not_equals2.ToString()}"); - Assert.False(equals1.Equals(not_equals3), $"{equals1.ToString()} equal to\n {not_equals3.ToString()}"); - Assert.False(equals1.Equals(not_equals4), $"{equals1.ToString()} equal to\n {not_equals4.ToString()}"); - Assert.False(equals1.Equals(not_equals5), $"{equals1.ToString()} equal to\n {not_equals5.ToString()}"); + + Assert.That(equals1, Is.Not.EqualTo(not_equals1)); + Assert.That(equals1, Is.Not.EqualTo(not_equals2)); + Assert.That(equals1, Is.Not.EqualTo(not_equals3)); + Assert.That(equals1, Is.Not.EqualTo(not_equals4)); + Assert.That(equals1, Is.Not.EqualTo(not_equals5)); } [Test] public void ApiDiagnosticBuffer_EntryEvent_EqualsCheck() @@ -1035,8 +1045,9 @@ public void ApiDiagnosticBuffer_EntryEvent_EqualsCheck() ApiDiagnosticBuffer_EntryEvent not_equals2 = new ApiDiagnosticBuffer_EntryEvent() { Textlist_Id = 2, Text_Id = 6 }; Assert.That(equals1.Equals(equals2), $"{equals1.ToString()} \n not equal to\n {equals2.ToString()}"); Assert.That(equals2.Equals(equals1), $"{equals2.ToString()} \n not equal to\n {equals1.ToString()}"); - Assert.False(equals1.Equals(not_equals1), $"{equals1.ToString()} \n equal to\n {not_equals1.ToString()}"); - Assert.False(equals1.Equals(not_equals2), $"{equals1.ToString()} \n equal to\n {not_equals2.ToString()}"); + + Assert.That(equals1, Is.Not.EqualTo(not_equals1)); + Assert.That(equals1, Is.Not.EqualTo(not_equals2)); } } } From 5bd30c6c9983e8da88b18172f90693dd5049e676 Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Mon, 21 Oct 2024 18:35:11 +0200 Subject: [PATCH 4/5] update dependencies --- src/Webserver.API/Webserver.API.csproj | 2 +- .../Webserver.Api.UnitTests.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Webserver.API/Webserver.API.csproj b/src/Webserver.API/Webserver.API.csproj index 80706ca..09d06f4 100644 --- a/src/Webserver.API/Webserver.API.csproj +++ b/src/Webserver.API/Webserver.API.csproj @@ -35,7 +35,7 @@ - + \ No newline at end of file diff --git a/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj b/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj index 1f0ea7e..9a5a7be 100644 --- a/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj +++ b/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj @@ -21,9 +21,9 @@ runtime; build; native; contentfiles; analyzers - - - + + + @@ -34,7 +34,7 @@ - + \ No newline at end of file From 1f905db2ef2d1e59cc47469e811265d0afb64a8e Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Mon, 21 Oct 2024 18:43:36 +0200 Subject: [PATCH 5/5] update dependencies --- src/Webserver.API/Webserver.API.csproj | 1 + tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Webserver.API/Webserver.API.csproj b/src/Webserver.API/Webserver.API.csproj index 09d06f4..55aa8d7 100644 --- a/src/Webserver.API/Webserver.API.csproj +++ b/src/Webserver.API/Webserver.API.csproj @@ -18,6 +18,7 @@ true product-simatic-s7-1500-256-256.png false + false diff --git a/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj b/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj index 9a5a7be..55c70f7 100644 --- a/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj +++ b/tests/Webserver.API.UnitTests/Webserver.Api.UnitTests.csproj @@ -27,7 +27,6 @@ -