当前位置: 首页>>代码示例>>C#>>正文


C# CacheManager.Store方法代码示例

本文整理汇总了C#中CacheManager.Store方法的典型用法代码示例。如果您正苦于以下问题:C# CacheManager.Store方法的具体用法?C# CacheManager.Store怎么用?C# CacheManager.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CacheManager的用法示例。


在下文中一共展示了CacheManager.Store方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestBasicCachingFunctionality

 public void TestBasicCachingFunctionality()
 {
     string objectToStore = "Test Object";
     CacheManager manager = new CacheManager(new MemoryProvider());
     manager.Store(objectToStore);
     Assert.AreEqual(objectToStore, manager.GetMostRecentCacheItem());
 }
开发者ID:neraath,项目名称:testing-in-sp2010,代码行数:7,代码来源:CacheManagerTests.cs

示例2: AlternativeWayToMockAnObject

 public void AlternativeWayToMockAnObject()
 {
     using (ShimsContext.Create())
     {
         ShimExtendableMemoryProvider.AllInstances.WriteInt64Object =
             (memoryProviderInstance, address, objToStore) =>
                 {
                     throw new AccessViolationException();
                 };
         CacheManager manager = new CacheManager(new ExtendableMemoryProvider());
         manager.Store("Test Object");
     }
 }
开发者ID:neraath,项目名称:testing-in-sp2010,代码行数:13,代码来源:CacheManagerTests.cs

示例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();
            }
        }
开发者ID:neraath,项目名称:testing-in-sp2010,代码行数:21,代码来源:CacheManagerTests.cs

示例4: TestOutOfBoundsExceptionWithStub

        public void TestOutOfBoundsExceptionWithStub()
        {
            using (ShimsContext.Create())
            {
                // Arrange.
                StubIMemoryModule memoryModule = new StubIMemoryModule();
                memoryModule.WriteInt64Object = (address, objToStore) =>
                    {
                        throw new AccessViolationException();
                    };
                CacheManager manager = new CacheManager(memoryModule);

                // Act.
                manager.Store("Test Object");
            }
        }
开发者ID:neraath,项目名称:testing-in-sp2010,代码行数:16,代码来源:CacheManagerTests.cs

示例5: 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);
            }
        }
开发者ID:neraath,项目名称:testing-in-sp2010,代码行数:30,代码来源:CacheManagerTests.cs

示例6: 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.");
            }
        }
开发者ID:neraath,项目名称:testing-in-sp2010,代码行数:23,代码来源:CacheManagerTests.cs


注:本文中的CacheManager.Store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。