SPRNET-1226

Update docs to reflect the requirement for a non-null, non-empty string cache key.  Added guard clauses in the BaseCacheAttribute constructor to prevent passing null or empty string as the cache key argument.  Tests added to ensure guard clauses behave as expected.
This commit is contained in:
sbohlen
2010-09-22 17:48:41 +00:00
parent 55d0c40aa8
commit 70d2b5413f
3 changed files with 218 additions and 182 deletions

View File

@@ -38,6 +38,16 @@ namespace Spring.Caching
private class DerivedCacheAttribute : BaseCacheAttribute
{
public DerivedCacheAttribute()
{
}
public DerivedCacheAttribute(string cacheName, string key)
: base(cacheName, key)
{
}
}
public string TestProperty
@@ -78,7 +88,21 @@ namespace Spring.Caching
public void AllowsForExtendedTimeSpanConverterSyntax()
{
att.TimeToLive = "5ms";
Assert.AreEqual( new TimeSpan(0,0,0,0,5), att.TimeToLiveTimeSpan );
Assert.AreEqual(new TimeSpan(0, 0, 0, 0, 5), att.TimeToLiveTimeSpan);
}
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void KeyCannotBeEmptyString()
{
att = new DerivedCacheAttribute("someName", string.Empty);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void KeyCannotBeNull()
{
att = new DerivedCacheAttribute("someName", null);
}
}
}