Skip to content

Commit

Permalink
Fixes #19
Browse files Browse the repository at this point in the history
+updated tests
  • Loading branch information
3F committed Aug 7, 2019
1 parent 04b843c commit bb41888
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
11 changes: 5 additions & 6 deletions MvsSln/Core/ConfigItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 38 additions & 0 deletions MvsSlnTest/Core/ConfigItemTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit bb41888

Please sign in to comment.