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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user