示例#1
0
        public void OrderSensitiveValueComparisonListTests_DefaultObjectComparer()
        {
            var equalityComparer = new DefaultObjectComparer <ArtifactChange>();

            var listOne = CreateTestList(equalityComparer);

            // Populate the second list with references from the first.
            var listTwo = new OrderSensitiveValueComparisonList <ArtifactChange>(equalityComparer);

            for (int i = 0; i < listOne.Count; i++)
            {
                listTwo.Add(listOne[i]);
            }

            // Every list s/be equal to itself.
            listOne.Equals(listOne).Should().Be(true);

            // Two lists with shared objects, by reference, in the same
            // order should be regarded as equivalent.
            listOne.Equals(listTwo).Should().Be(true);

            ArtifactChange toSwap = listTwo[0];

            listTwo[0] = listTwo[1];
            listTwo[1] = toSwap;

            // We have reordered two objects that are themselves identical.
            // The comparison should fail as the order of references changed.
            listOne.Equals(listTwo).Should().Be(false);
        }
示例#2
0
        private static OrderSensitiveValueComparisonList <Artifact> ConstructFilesChain(IList <Artifact> existingFiles, Artifact currentFile)
        {
            var fileChain = new OrderSensitiveValueComparisonList <Artifact>(Artifact.ValueComparer);

            int parentIndex;

            do
            {
                currentFile = currentFile.DeepClone();
                parentIndex = currentFile.ParentIndex;

                // Index information is entirely irrelevant for the identity of nested files,
                // as each element of the chain could be stored at arbitrary locations in
                // the run.files table. And so we elide this information.
                currentFile.ParentIndex = -1;
                if (currentFile.Location != null)
                {
                    currentFile.Location.Index = -1;
                }

                fileChain.Add(currentFile);

                if (parentIndex != -1)
                {
                    currentFile = existingFiles[parentIndex];
                }
            } while (parentIndex != -1);

            return(fileChain);
        }
示例#3
0
        private static OrderSensitiveValueComparisonList <LogicalLocation> ConstructLogicalLocationsChain(
            LogicalLocation currentLogicalLocation,
            IList <LogicalLocation> existingLogicalLocations)
        {
            var logicalLocationChain = new OrderSensitiveValueComparisonList <LogicalLocation>(LogicalLocation.ValueComparer);

            int parentIndex;

            do
            {
                currentLogicalLocation = currentLogicalLocation.DeepClone();
                parentIndex            = currentLogicalLocation.ParentIndex;

                // Index information is entirely irrelevant for the identity of nested logical locations,
                // as each element of the chain could be stored at arbitrary locations in the
                // run.logicalLocations table. And so we elide this information.
                currentLogicalLocation.ParentIndex = -1;
                currentLogicalLocation.Index       = -1;

                logicalLocationChain.Add(currentLogicalLocation);

                if (parentIndex != -1)
                {
                    currentLogicalLocation = existingLogicalLocations[parentIndex];
                }
            } while (parentIndex != -1);

            return(logicalLocationChain);
        }