Пример #1
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");
        }
Пример #2
0
        public void AddRemoveBuildResults()
        {
            BuildPropertyGroup default_scope = new BuildPropertyGroup();
            CacheScope         testScope     = new CacheScope("Test.proj", new BuildPropertyGroup(), "2.0");

            // First add a single empty result (expect no crash)
            testScope.AddCacheEntryForBuildResults(resultWith0Outputs);
            // Add a single result - expect to find target in the cache
            testScope.AddCacheEntryForBuildResults(resultWith1Outputs);
            Assert.IsTrue(testScope.ContainsCacheEntry("Target1"), "Expected entry in the cache");
            Assert.IsNotNull(testScope.GetCacheEntry("Target1"), "Cache should have an entry");
            // Add a double result expect both target in the entry
            testScope.AddCacheEntryForBuildResults(resultWith2Outputs);
            Assert.IsTrue(testScope.ContainsCacheEntry("Target2"), "Expected entry in the cache");
            Assert.IsNotNull(testScope.GetCacheEntry("Target2"), "Cache should have an entry");
            Assert.IsTrue(testScope.ContainsCacheEntry("Target3"), "Expected entry in the cache");
            Assert.IsNotNull(testScope.GetCacheEntry("Target3"), "Cache should have an entry");
            // Double add a result ( expect no crash since it is identical )
            testScope.AddCacheEntryForBuildResults(resultWith1Outputs);
            // Add an uncacheable result and verify that it is not in the cache
            testScope.AddCacheEntryForBuildResults(uncacheableResult);
            Assert.IsFalse(testScope.ContainsCacheEntry("Target4"), "Didn't expect entry in the cache");
            Assert.IsNull(testScope.GetCacheEntry("Target4"), "Cache should  not have an entry");
        }