Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Feb 25, 2024
1 parent 53a0e52 commit 3f49be5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<string> { "/", testFolderPath });
var selectorStorage = new FakeSelectorStorage(storage);
Expand All @@ -66,7 +65,6 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success_CompareJson()
{
StorageFolder = testFolderPath,
Verbose = true,
UseLocalDesktop = null
};

// Act
Expand All @@ -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]
Expand Down Expand Up @@ -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()
{
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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]);
}
}

0 comments on commit 3f49be5

Please sign in to comment.