Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
AliveDevil committed Nov 25, 2024
1 parent 985eb14 commit 48197b9
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using java.util;
using NUnit.Framework;
using System.Collections.Generic;

namespace Ch.Cyberduck.Core.Preferences;

Expand All @@ -18,10 +19,36 @@ public void LocaleDisplayNames()
}
}

[TestCase]
public void PersistsEmptyValue()
{
TestPreferences preferences = new([
new("test.empty.default", "DONT")
]);
preferences.load();

Assert.AreEqual("DONT", preferences.getDefault("test.empty.default"));
preferences.setProperty("test.empty.default", "");
Assert.AreEqual("DONT", preferences.getDefault("test.empty.default"));
Assert.AreEqual("", preferences.getProperty("test.empty.default"));
}

public class TestPreferences : ApplicationPreferences<TestPreferences>
{
public TestPreferences() : base(new DefaultLocales(), new PropertyStoreFactory<MemoryPropertyStore>())
private readonly IEnumerable<KeyValuePair<string, string>> testDefaults;

public TestPreferences(params KeyValuePair<string, string>[] testDefaults) : base(new DefaultLocales(), new PropertyStoreFactory<MemoryPropertyStore>())
{
this.testDefaults = testDefaults;
}

protected override void setDefaults()
{
base.setDefaults();
foreach (var item in testDefaults)
{
setDefault(item.Key, item.Value);
}
}
}
}

0 comments on commit 48197b9

Please sign in to comment.