mirror of
https://github.com/iterate-ch/cyberduck.git
synced 2026-05-26 19:10:49 +00:00
Remove string empty check in getProperty
This commit is contained in:
@@ -96,7 +96,7 @@ public class ApplicationPreferences<T> : DefaultPreferences
|
||||
|
||||
public override string getProperty(string property)
|
||||
{
|
||||
if (propertyStore[property] is not { } value || string.IsNullOrWhiteSpace(value))
|
||||
if (propertyStore[property] is not { } value)
|
||||
{
|
||||
value = getDefault(property);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using java.util;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ch.Cyberduck.Core.Preferences;
|
||||
|
||||
@@ -18,10 +19,46 @@ public class ApplicationPreferencesTests
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void PersistsEmptyValue()
|
||||
{
|
||||
TestPreferences preferences = new();
|
||||
preferences.setDefaults([
|
||||
new("test.empty.default", "DONT")
|
||||
]);
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void OverrideDefaultsDefault()
|
||||
{
|
||||
TestPreferences preferences = new();
|
||||
preferences.setDefaults([
|
||||
/* Mimick Cyberduck Defaults */
|
||||
new("test.core.override", "CORE"),
|
||||
/* Override in downstream Defaults */
|
||||
new("test.core.override", "")
|
||||
]);
|
||||
|
||||
Assert.IsEmpty(preferences.getProperty("test.core.override"));
|
||||
}
|
||||
|
||||
public class TestPreferences : ApplicationPreferences<TestPreferences>
|
||||
{
|
||||
public TestPreferences() : base(new DefaultLocales(), new PropertyStoreFactory<MemoryPropertyStore>())
|
||||
{
|
||||
}
|
||||
|
||||
public void setDefaults(params KeyValuePair<string, string>[] testDefaults)
|
||||
{
|
||||
foreach (var item in testDefaults)
|
||||
{
|
||||
setDefault(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user