achieved 100% test coverage for the read only collection wrapper; optimized the indexer of the license key class; increased test coverage for the license key class to 100%

git-svn-id: file:///srv/devel/repo-conversion/nusu@95 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2008-11-27 19:02:48 +00:00
parent c43bfd47c8
commit de7c28fa84
5 changed files with 218 additions and 8 deletions

View file

@ -31,6 +31,13 @@ namespace Nuclex.Support.Licensing {
[TestFixture]
public class LicenseKeyTest {
/// <summary>Tests the default constructor of the license key class</summary>
[Test]
public void TestDefaultConstructor() {
new LicenseKey();
}
/// <summary>Validates the correct translation of keys to GUIDs and back</summary>
[Test]
public void TestGuidKeyConversion() {
@ -88,6 +95,43 @@ namespace Nuclex.Support.Licensing {
}
/// <summary>Tests whether license keys can be modified without destroying them</summary>
[Test, ExpectedException(typeof(ArgumentException))]
public void TestParseInvalidLicenseKey() {
LicenseKey.Parse("hello world");
}
/// <summary>
/// Tests whether an exception is thrown if the indexer of a license key is used
/// with an invalid index to retrieve a component of the key
/// </summary>
[Test, ExpectedException(typeof(IndexOutOfRangeException))]
public void TestGetByIndexerWithInvalidIndex() {
LicenseKey key = new LicenseKey();
int indexMinusOne = key[-1];
}
/// <summary>
/// Tests whether an exception is thrown if the indexer of a license key is used
/// with an invalid index to set a component of the key
/// </summary>
[Test, ExpectedException(typeof(IndexOutOfRangeException))]
public void TestSetByIndexerWithInvalidIndex() {
LicenseKey key = new LicenseKey();
key[-1] = 0;
}
/// <summary>
/// Verifies that a license key can be converted into a byte array
/// </summary>
[Test]
public void TestToByteArray() {
Guid someGuid = Guid.NewGuid();
LicenseKey someKey = new LicenseKey(someGuid);
CollectionAssert.AreEqual(someGuid.ToByteArray(), someKey.ToByteArray());
}
}
} // namespace Nuclex.Support.Licensing