Beispiel #1
0
        public void Error_Thrown_When_Selecting_Merged_Version_Of_Conflict()
        {
            TwoWayDiff diffAlgorithm = new TwoWayDiff();
            DiffResult result        = diffAlgorithm.PerformDiff("Common Text\nLeft Text\nCommon Text2", "Common Text\nRight Text\nCommon Text2");

            Assert.That(result.MergedSuccessfully, Is.False, "Merge should not have been successful");
            Assert.That(result.ConflictBlocks.Count, Is.EqualTo(1), "Wrong number of Blocks in conflict");
            Assert.That(result.BlockCount, Is.EqualTo(3), "Wrong number of blocks.");

            result.SelectVersionOfConflict(1, ObjectVersion.Merged);
        }
Beispiel #2
0
        private void Select_One_Version_Of_Conflict(ObjectVersion versionToUse, string mergedText)
        {
            TwoWayDiff diffAlgorithm = new TwoWayDiff();
            DiffResult result        = diffAlgorithm.PerformDiff("Common Text\nLeft Text\nCommon Text2", "Common Text\nRight Text\nCommon Text2");

            Assert.That(result.MergedSuccessfully, Is.False, "Merge should not have been successful");
            Assert.That(result.ConflictBlocks.Count, Is.EqualTo(1), "Wrong number of Blocks in conflict");
            Assert.That(result.BlockCount, Is.EqualTo(3), "Wrong number of blocks.");

            // Use the Left text for the conflict.
            result.SelectVersionOfConflict(1, versionToUse);

            ReadOnlyCollection <ObjectList <Block> > blocks = result.GetBlocks();

            Block left   = blocks[0].Left;
            Block right  = blocks[0].Right;
            Block merged = blocks[0].Merged;

            CommonTests.CheckBlocksAreNotNull(left, right, merged);
            Assert.That(blocks[0].Base, Is.Null, "Base is not null");

            CommonTests.AssertAllHaveSameSingleLineOfText(left, right, merged, "Common Text");

            left   = blocks[1].Left;
            right  = blocks[1].Right;
            merged = blocks[1].Merged;

            CommonTests.AssertAllHaveOneLineOfText(left, right, merged);

            CommonTests.AssertSingleLineOfTextIneachVersionIsEqualTo(left, right, merged, "Left Text", "Right Text", mergedText);

            left   = blocks[2].Left;
            right  = blocks[2].Right;
            merged = blocks[2].Merged;

            CommonTests.CheckBlocksAreNotNull(left, right, merged);
            Assert.That(blocks[0].Base, Is.Null, "Base is not null");

            CommonTests.AssertAllHaveSameSingleLineOfText(left, right, merged, "Common Text2");

            Assert.That(result.MergedSuccessfully, Is.True, "MergedSucessfully was not set to true after all conflicts handled.");
        }
Beispiel #3
0
        public void Remove_Line_Of_Text_Weve_Just_Added()
        {
            TwoWayDiff diffAlgorithm = new TwoWayDiff();
            DiffResult result        = diffAlgorithm.PerformDiff("Common Text\nLeft Text\nCommon Text2", "Common Text\nRight Text\nCommon Text2");

            Assert.That(result.MergedSuccessfully, Is.False);

            result.SelectVersionOfConflict(1, ObjectVersion.Left);

            Assert.That(result.MergedSuccessfully, Is.True);

            result.InsertLine(1, 0, "New Text");

            Assert.That(result.Merged.Lines.Count, Is.EqualTo(5));
            Assert.That(result.Merged.Lines[1], Is.EqualTo("New Text"));
            Assert.That(result.MergedSuccessfully, Is.False);

            // Change the line back
            result.RemoveLine(1, 0);

            Assert.That(result.Merged.Lines[1], Is.EqualTo("Left Text"));
            Assert.That(result.MergedSuccessfully, Is.True);
        }