Exemple #1
0
            public void CorrectlyConvertsDelete()
            {
                // Arrange
                var diff = new FileDiff("OldFile", "/dev/null",
                    new DiffHunk(new SourceCoordinate(0, 0), new SourceCoordinate(10, 0), String.Empty,
                        new LineDiff(LineDiffType.Removed, "Foo"),
                        new LineDiff(LineDiffType.Removed, "Bar"),
                        new LineDiff(LineDiffType.Removed, "Baz")));

                // Act
                var actual = new DiffConverter().ConvertFile(diff);

                // Assert
                Assert.Equal(FileChangeType.Removed, actual.ChangeType);
                Assert.Equal("OldFile", actual.FileName);
                Assert.Equal(@"@@ -0,0 +10,0 @@
                -Foo
                -Bar
                -Baz",
                    actual.Diff);
            }
            public void CorrectlyConvertsDelete()
            {
                // Arrange
                var diff = new FileDiff("OldFile", "/dev/null",
                    new DiffHunk(new SourceCoordinate(0, 0), new SourceCoordinate(10, 0), String.Empty,
                        new LineDiff(LineDiffType.Removed, "Foo"),
                        new LineDiff(LineDiffType.Removed, "Bar"),
                        new LineDiff(LineDiffType.Removed, "Baz")));

                // Act
                var actual = new DiffConverter().ConvertFile(diff);

                // Assert
                Assert.Equal(new Data.FileDeletion()
                {
                    FileName = "NewFile",
                    Diff = @"@@ -0,0 +10,0 @@
                -Foo
                -Bar
                -Baz"
                }, actual, new PropertyEqualityComparer());
            }
Exemple #3
0
            public void CorrectlyConvertsModification()
            {
                // Arrange
                var diff = new FileDiff("OldFile", "NewFile",
                    new DiffHunk(new SourceCoordinate(0, 0), new SourceCoordinate(10, 0), String.Empty,
                        new LineDiff(LineDiffType.Added, "Foo"),
                        new LineDiff(LineDiffType.Removed, "Bar"),
                        new LineDiff(LineDiffType.Same, "Baz")));

                // Act
                var actual = new DiffConverter().ConvertFile(diff);

                // Assert
                Assert.Equal(FileChangeType.Modified, actual.ChangeType);
                Assert.Equal("OldFile", actual.FileName);
                Assert.Equal("NewFile", actual.NewFileName);
                Assert.Equal(@"@@ -0,0 +10,0 @@
                +Foo
                -Bar
                 Baz",
                    actual.Diff);
            }
Exemple #4
0
 public DiffService(DiffReader reader, DiffConverter converter)
 {
     Reader = reader;
     Converter = converter;
 }
            public void RemovesPrefixesFromGitPaths()
            {
                // Arrange
                var diff = new FileDiff("a/Foo/Bar", "b/Biz/Baz",
                    new DiffHunk(new SourceCoordinate(0, 0), new SourceCoordinate(10, 0), String.Empty,
                        new LineDiff(LineDiffType.Added, "Foo"),
                        new LineDiff(LineDiffType.Removed, "Bar"),
                        new LineDiff(LineDiffType.Same, "Baz")));

                // Act
                var actual = new DiffConverter().ConvertFile(diff);

                // Assert
                Assert.Equal(new Data.FileModification()
                {
                    FileName = "/Foo/Bar",
                    NewFileName = "/Biz/Baz",
                    Diff = @"@@ -0,0 +10,0 @@
                +Foo
                -Bar
                 Baz"
                }, actual, new PropertyEqualityComparer());
            }
Exemple #6
0
            public void RemovesPrefixesFromGitPaths()
            {
                // Arrange
                var diff = new FileDiff("a/Foo/Bar", "b/Biz/Baz",
                    new DiffHunk(new SourceCoordinate(0, 0), new SourceCoordinate(10, 0), String.Empty,
                        new LineDiff(LineDiffType.Added, "Foo"),
                        new LineDiff(LineDiffType.Removed, "Bar"),
                        new LineDiff(LineDiffType.Same, "Baz")));

                // Act
                var actual = new DiffConverter().ConvertFile(diff);

                // Assert
                Assert.Equal(FileChangeType.Modified, actual.ChangeType);
                Assert.Equal("/Foo/Bar", actual.FileName);
                Assert.Equal("/Biz/Baz", actual.NewFileName);
                Assert.Equal(@"@@ -0,0 +10,0 @@
                +Foo
                -Bar
                 Baz",
                    actual.Diff);
            }