diff --git a/MvsSln/Core/ConfigItem.cs b/MvsSln/Core/ConfigItem.cs index b80ca35..9d3e3e5 100644 --- a/MvsSln/Core/ConfigItem.cs +++ b/MvsSln/Core/ConfigItem.cs @@ -171,17 +171,16 @@ public ConfigItem(string configuration, string platform) public ConfigItem(string formatted) { - if(String.IsNullOrWhiteSpace(formatted)) { + if(formatted == null) { return; } string[] cfg = formatted.Split('|'); - if(cfg.Length < 2) { - throw new ArgumentException($"The format `{formatted}` of configuration is not supported."); - } - Configuration = cfg[0]; - Platform = cfg[1]; + Configuration = cfg[0]; + + // < 2 https://github.com/3F/MvsSln/issues/19 + Platform = cfg.Length < 2 ? string.Empty : cfg[1]; } protected virtual string Sensitivity(string name) diff --git a/MvsSlnTest/Core/ConfigItemTest.cs b/MvsSlnTest/Core/ConfigItemTest.cs index 977adf6..f5c4c70 100644 --- a/MvsSlnTest/Core/ConfigItemTest.cs +++ b/MvsSlnTest/Core/ConfigItemTest.cs @@ -82,5 +82,43 @@ public void IsEqualByRuleTest1() Assert.AreEqual(false, target.IsEqualByRule(null, null, false)); Assert.AreEqual(false, target.IsEqualByRule(null, null, true)); } + + [TestMethod] + public void NoPlatformTest1() + { + var target = new ConfigItem("Config"); + + Assert.AreEqual("Config", target.Configuration); + Assert.AreEqual(string.Empty, target.Platform); + + target = new ConfigItem("Config|"); + + Assert.AreEqual("Config", target.Configuration); + Assert.AreEqual(string.Empty, target.Platform); + + target = new ConfigItem("Config| "); + + Assert.AreEqual("Config", target.Configuration); + Assert.AreEqual(" ", target.Platform); + } + + [TestMethod] + public void CtorTest1() + { + var target = new ConfigItem(""); + + Assert.AreEqual(string.Empty, target.Configuration); + Assert.AreEqual(string.Empty, target.Platform); + + target = new ConfigItem(" "); + + Assert.AreEqual(" ", target.Configuration); + Assert.AreEqual(string.Empty, target.Platform); + + target = new ConfigItem(null); + + Assert.AreEqual(null, target.Configuration); + Assert.AreEqual(null, target.Platform); + } } }