diff --git a/core/src/test/csharp/ch/cyberduck/core/preferences/ApplicationPreferencesTests.cs b/core/src/test/csharp/ch/cyberduck/core/preferences/ApplicationPreferencesTests.cs index de81a26d7c5..9ef96d854ca 100644 --- a/core/src/test/csharp/ch/cyberduck/core/preferences/ApplicationPreferencesTests.cs +++ b/core/src/test/csharp/ch/cyberduck/core/preferences/ApplicationPreferencesTests.cs @@ -1,5 +1,6 @@ using java.util; using NUnit.Framework; +using System.Collections.Generic; namespace Ch.Cyberduck.Core.Preferences; @@ -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 { - public TestPreferences() : base(new DefaultLocales(), new PropertyStoreFactory()) + private readonly IEnumerable> testDefaults; + + public TestPreferences(params KeyValuePair[] testDefaults) : base(new DefaultLocales(), new PropertyStoreFactory()) + { + this.testDefaults = testDefaults; + } + + protected override void setDefaults() { + base.setDefaults(); + foreach (var item in testDefaults) + { + setDefault(item.Key, item.Value); + } } } }