本文整理汇总了C#中CacheManager.GetMostRecentCacheItem方法的典型用法代码示例。如果您正苦于以下问题:C# CacheManager.GetMostRecentCacheItem方法的具体用法?C# CacheManager.GetMostRecentCacheItem怎么用?C# CacheManager.GetMostRecentCacheItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheManager
的用法示例。
在下文中一共展示了CacheManager.GetMostRecentCacheItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBasicCachingFunctionality
public void TestBasicCachingFunctionality()
{
string objectToStore = "Test Object";
CacheManager manager = new CacheManager(new MemoryProvider());
manager.Store(objectToStore);
Assert.AreEqual(objectToStore, manager.GetMostRecentCacheItem());
}
示例2: TestMockingTheExtendableMemoryProvider
public void TestMockingTheExtendableMemoryProvider()
{
using (ShimsContext.Create())
{
// Arrange.
ShimExtendableMemoryProvider memoryProviderMock = new ShimExtendableMemoryProvider();
object objectStored = null;
long storedAtAddress = -1;
memoryProviderMock.WriteInt64Object = (address, objToStore) =>
{
storedAtAddress = address;
objectStored = objToStore;
};
memoryProviderMock.ReadInt64 = (address) =>
{
if (address != storedAtAddress)
throw new ArgumentOutOfRangeException();
return objectStored;
};
CacheManager manager = new CacheManager(memoryProviderMock.Instance);
// Act.
string objectToStore = "Test Object";
manager.Store(objectToStore);
object objectRead = manager.GetMostRecentCacheItem();
// Assert.
Assert.AreEqual(objectToStore, objectRead);
}
}
示例3: TestToShowPassthruCapabilities
public void TestToShowPassthruCapabilities()
{
using (ShimsContext.Create())
{
object objectStored = null;
// This is setting the behavior to the "default" behavior of fallthru.
Microsoft.QualityTools.Testing.Fakes.Shims.ShimBehaviors.BehaveAsFallthrough();
ShimExtendableMemoryProvider.BehaveAsCurrent();
ShimExtendableMemoryProvider.AllInstances.WriteInt64Object = (instance, address, objToStore) =>
{
objectStored = objToStore;
};
CacheManager manager = new CacheManager(new ExtendableMemoryProvider());
// Act.
manager.Store("Test");
object mostRecentItem = manager.GetMostRecentCacheItem();
}
}
示例4: TestCachingWithStub
public void TestCachingWithStub()
{
using (ShimsContext.Create())
{
// Arrange.
StubIMemoryModule memoryModule = new StubIMemoryModule();
object objectWritten = null;
memoryModule.WriteInt64Object = (address, objectToWrite) =>
{
objectWritten = objectToWrite;
};
memoryModule.ReadInt64 = (address) => objectWritten;
CacheManager manager = new CacheManager(memoryModule);
string myObj = "Test Object";
// Act.
manager.Store(myObj);
object retrievedOjbect = manager.GetMostRecentCacheItem();
// Assert.
Assert.AreEqual(myObj, retrievedOjbect, "Retrieved object is not the same as stored.");
}
}