Пример #1
0
        public void AddResultToCache()
        {
            Assert.IsNull(cacheScope.GetCacheEntry("TaskItems"), "Cache should not have an entry");
            NodeRequestMapping requestMapping = new NodeRequestMapping(1, 1, cacheScope);

            Assert.AreEqual(1, requestMapping.HandleId, "Expected NodeProxyId to be 1");
            Assert.AreEqual(1, requestMapping.RequestId, "Expected RequestId to be 1");
            requestMapping.AddResultToCache(resultWithOutputs);
            Assert.IsTrue(resultWithOutputs.EvaluationResult == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildResult,
                          "Expected EvaluationResult to be the same after it was retrieved from the cache");
            Assert.IsTrue(((BuildItem[])resultWithOutputs.OutputsByTarget["TaskItems"])[0].Include == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildItems[0].Include,
                          "Expected EvaluationResult to be the same after it was retrieved from the cache");
            // Remove the entry from the cache
            cacheScope.ClearCacheEntry("TaskItems");
        }
Пример #2
0
        public void BasicCacheOperation()
        {
            BuildPropertyGroup default_scope = new BuildPropertyGroup();
            CacheScope         testScope     = new CacheScope("Test.proj", new BuildPropertyGroup(), "2.0");
            // First add a single entry and verify that it is in the cache
            CacheEntry cacheEntry = new BuildResultCacheEntry("TestEntry", null, true);

            testScope.AddCacheEntry(cacheEntry);
            Assert.IsTrue(testScope.ContainsCacheEntry("TestEntry"), "Expect entry in the cache");
            CacheEntry inCacheEntry = testScope.GetCacheEntry("TestEntry");

            Assert.IsNotNull(inCacheEntry, "Cache should have an entry");
            Assert.IsTrue(inCacheEntry.IsEquivalent(cacheEntry), "Expect entry to be the same");
            // Add a second entry and then remove the first entry. Verify that the first entry
            // is not in the cache while the second entry is still there
            cacheEntry = new BuildResultCacheEntry("TestEntry2", null, true);
            testScope.AddCacheEntry(cacheEntry);
            testScope.ClearCacheEntry("TestEntry");
            Assert.IsFalse(testScope.ContainsCacheEntry("TestEntry"), "Didn't expect entry in the cache");
            Assert.IsTrue(testScope.ContainsCacheEntry("TestEntry2"), "Expected entry in the cache");
            Assert.IsNull(testScope.GetCacheEntry("TestEntry"), "Cache should  not have an entry");
            Assert.IsNotNull(testScope.GetCacheEntry("TestEntry2"), "Cache should have an entry");
        }