From 3f49be52dbbc7bc0d9cc3b0e86b483515fc2e772 Mon Sep 17 00:00:00 2001 From: Dion Date: Sun, 25 Feb 2024 12:35:33 +0100 Subject: [PATCH] fix tests --- .../Services/UpdateAppSettingsByPathTest.cs | 18 ++++----- .../Models/AppSettingsTransferObjectTest.cs | 37 +++++++++++++++++++ 2 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 starsky/starskytest/starsky.foundation.platform/Models/AppSettingsTransferObjectTest.cs diff --git a/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs b/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs index 41f0ccecbf..e5cc6f148a 100644 --- a/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs +++ b/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs @@ -32,8 +32,7 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success() new UpdateAppSettingsByPath(new AppSettings(), selectorStorage); var appSettingTransferObject = new AppSettingsTransferObject { - StorageFolder = testFolderPath, - Verbose = true + StorageFolder = testFolderPath, Verbose = true }; // Act @@ -55,8 +54,8 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success_CompareJson() var before = Environment.GetEnvironmentVariable("app__storageFolder"); Environment.SetEnvironmentVariable("app__storageFolder", string.Empty); - var testFolderPath = Path.DirectorySeparatorChar.ToString() + "test" + - Path.DirectorySeparatorChar.ToString(); + var testFolderPath = Path.DirectorySeparatorChar + "test" + + Path.DirectorySeparatorChar; var storage = new FakeIStorage(new List { "/", testFolderPath }); var selectorStorage = new FakeSelectorStorage(storage); @@ -66,7 +65,6 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success_CompareJson() { StorageFolder = testFolderPath, Verbose = true, - UseLocalDesktop = null }; // Act @@ -86,9 +84,10 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success_CompareJson() // Assert var expectedResult = "{\n \"app\": {\n \"Verbose\": \"true\",\n \"StorageFolder\": " + // rm quotes - storageFolderJson + ",\n \"UseLocalDesktop\": \"false\"\n }\n}"; + storageFolderJson + ",\n"; - Assert.AreEqual(expectedResult, result); + + Assert.AreEqual(true, result.Contains(expectedResult)); } [TestMethod] @@ -195,7 +194,7 @@ await StreamToStringHelper.StreamToStringAsync( Assert.AreEqual(testFolderPath, fileResult2.App.StorageFolder); Assert.IsTrue(fileResult2.App.Verbose); } - + [TestMethod] public async Task UpdateAppSettingsAsync_ValidInput_Success1() { @@ -205,8 +204,7 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success1() new UpdateAppSettingsByPath(new AppSettings(), selectorStorage); var appSettingTransferObject = new AppSettingsTransferObject { - DesktopCollectionsOpen = CollectionsOpenType.RawJpegMode.Raw, - Verbose = true + DesktopCollectionsOpen = CollectionsOpenType.RawJpegMode.Raw, Verbose = true }; // Act diff --git a/starsky/starskytest/starsky.foundation.platform/Models/AppSettingsTransferObjectTest.cs b/starsky/starskytest/starsky.foundation.platform/Models/AppSettingsTransferObjectTest.cs new file mode 100644 index 0000000000..222f66acda --- /dev/null +++ b/starsky/starskytest/starsky.foundation.platform/Models/AppSettingsTransferObjectTest.cs @@ -0,0 +1,37 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using starsky.foundation.platform.Helpers; +using starsky.foundation.platform.Models; + +namespace starskytest.starsky.foundation.platform.Models; + +[TestClass] +public class AppSettingsTransferObjectTest +{ + [TestMethod] + public void AppSettingsTransferObject_Verbose() + { + var appSettingsTransferObject = new AppSettingsTransferObject + { + Verbose = true, + StorageFolder = "test", + UseSystemTrash = true, + UseLocalDesktop = true, + DefaultDesktopEditor = + [ + new AppSettingsDefaultEditorApplication + { + ApplicationPath = "app", + ImageFormats = [ExtensionRolesHelper.ImageFormat.bmp] + } + ] + }; + + Assert.AreEqual(true, appSettingsTransferObject.Verbose); + Assert.AreEqual("test", appSettingsTransferObject.StorageFolder); + Assert.AreEqual(true, appSettingsTransferObject.UseSystemTrash); + Assert.AreEqual(true, appSettingsTransferObject.UseLocalDesktop); + Assert.AreEqual("app", appSettingsTransferObject.DefaultDesktopEditor[0].ApplicationPath); + Assert.AreEqual(ExtensionRolesHelper.ImageFormat.bmp, + appSettingsTransferObject.DefaultDesktopEditor[0].ImageFormats[0]); + } +}