Skip to content

Commit

Permalink
test: adds tests to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bolorundurowb committed Feb 12, 2017
1 parent 0329f0a commit 4ed0230
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion PropertyConfig.Tests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;

namespace PropertyConfig.Tests
{
Expand Down Expand Up @@ -39,5 +41,47 @@ public void LoadFromXMLTest()
});
Assert.AreEqual(configuration["Hello"], "World");
}

[Test]
public void DefaultConfigFileTest()
{
Configuration configuration = new Configuration();
Assert.AreEqual(configuration.FilePath, "config.xml");
Assert.DoesNotThrow(delegate {
configuration.FilePath = "new_config.xml";
});
Assert.AreEqual(configuration.FilePath, "new_config.xml");
}

[Test]
public void RetrievePropertyTest()
{
Configuration configuration = new Configuration();
Assert.AreEqual(configuration.GetProperty("Hello"), null);
}

[Test]
public void RetrieveNonExistingPropertyWithDefaultTest()
{
Configuration configuration = new Configuration();
Assert.AreEqual(configuration.GetProperty("Hello", "World"), "World");
}

[Test]
public void RetrieveExistingPropertyWithDefaultTest()
{
Configuration configuration = new Configuration();
configuration.SetProperty("Hello", "World");
Assert.AreEqual(configuration.GetProperty("Hello", "World"), "World");
}

[Test]
public void RetrieveAllKeysTest()
{
Configuration configuration = new Configuration();
configuration.SetProperty("Hello", "World");
List<string> keys = configuration.PropertyNames().ToList();
Assert.AreEqual(keys.Count, 1);
}
}
}

0 comments on commit 4ed0230

Please sign in to comment.