public void OutputCacheShouldNotContainInformationFromInputCaches()
        {
            var topoSortedNodes =
                CreateProjectGraph(
                    env: _env,
                    dependencyEdges: new Dictionary <int, int[]> {
                { 1, new[] { 2, 3 } }
            },
                    globalProperties: null,
                    createProjectFile: CreateProjectFileWrapper)
                .ProjectNodesTopologicallySorted.ToArray();

            var expectedOutput = new ExpectedNodeBuildOutput();

            var outputCaches = new OutputCacheDictionary();

            BuildUsingCaches(topoSortedNodes, expectedOutput, outputCaches, generateCacheFiles: true);

            var rootNode    = topoSortedNodes.First(n => Path.GetFileNameWithoutExtension(n.ProjectInstance.FullPath) == "1");
            var outputCache = outputCaches[rootNode];

            outputCache.ShouldNotBeNull();

            var deserializationInfo = CacheSerialization.DeserializeCaches(outputCache);

            deserializationInfo.exception.ShouldBeNull();

            var buildResults = deserializationInfo.ResultsCache.GetEnumerator().ToArray();

            buildResults.ShouldHaveSingleItem();

            var rootNodeBuildResult = buildResults.First();

            rootNodeBuildResult.ResultsByTarget["Build"].Items.Select(i => i.ItemSpec).ToArray().ShouldBe(expectedOutput[rootNode]);

            var configEntries = deserializationInfo.ConfigCache.GetEnumerator().ToArray();

            configEntries.ShouldHaveSingleItem();

            configEntries.First().ConfigurationId.ShouldBe(rootNodeBuildResult.ConfigurationId);
        }
Esempio n. 2
0
 /// <summary>
 /// Construct a module with caching
 /// </summary>
 /// <param name="name">Name of the module</param>
 /// <param name="dependentOn">List of names of other modules this is dependent on (these will start up before this one)</param>
 public Cache(string name, params string[] dependentOn) : base(name, dependentOn)
 {
     SerializationMode = CacheSerialization.Binary;
 }