Пример #1
0
        public void ThrowsForNotAvailableRepo()
        {
            var mockNote = new Mock <INotificationManager>();
            var plugin   = new SQGitPlugin(mockNote.Object) as ISourceVersionPlugin;

            Assert.Throws <NullReferenceException>(() => plugin.InitializeRepository("c:\\windows"));
        }
Пример #2
0
        public void CorrectlyGetBranchIfNotRootRepo()
        {
            var mockNote      = new Mock <INotificationManager>();
            var plugin        = new SQGitPlugin(mockNote.Object) as ISourceVersionPlugin;
            var sourceDirPath = Directory.GetParent(Directory.GetParent(this.executionPath).ToString()).ToString();
            var repo          = Path.Combine(sourceDirPath, "TestData", "sonar-doxygen", "src");

            plugin.InitializeRepository(repo);
            Assert.That(plugin.GetBranch(), Is.EqualTo("origin/master"));
        }
Пример #3
0
 public void CorrectlyBlamesLine()
 {
     var mockNote = new Mock<INotificationManager>();
     var plugin = new SQGitPlugin(mockNote.Object);
     plugin.UseCommandLine = false;
     var sourceDirPath = Directory.GetParent(Directory.GetParent(this.executionPath).ToString()).ToString();
     var repo = Path.Combine(sourceDirPath, "TestData", "sonar-doxygen");
     plugin.InitializeRepository(repo);
     var lineBlame = plugin.GetBlameByLine(Path.Combine(repo, "pom.xml"), 10);
     Assert.That(lineBlame, Is.Not.Null);
 }
Пример #4
0
        public void CorrectlyBlamesLine()
        {
            var mockNote = new Mock <INotificationManager>();
            var plugin   = new SQGitPlugin(mockNote.Object);

            plugin.UseCommandLine = false;
            var sourceDirPath = Directory.GetParent(Directory.GetParent(this.executionPath).ToString()).ToString();
            var repo          = Path.Combine(sourceDirPath, "TestData", "sonar-doxygen");

            plugin.InitializeRepository(repo);
            var lineBlame = plugin.GetBlameByLine(Path.Combine(repo, "pom.xml"), 10);

            Assert.That(lineBlame, Is.Not.Null);
        }
Пример #5
0
        public void CorrectlyBlamesLineByCommandLine()
        {
            var lines = File.ReadLines(Path.Combine(this.executionPath, "data", "blame.txt")).ToList();

            var mockNote = new Mock<INotificationManager>();
            var mockCommand = new Mock<IVSSonarQubeCmdExecutor>();
            mockCommand.Setup(x => x.GetStdOut()).Returns(lines);

            var plugin = new SQGitPlugin(mockNote.Object, mockCommand.Object) as ISourceVersionPlugin;
            var sourceDirPath = Directory.GetParent(Directory.GetParent(this.executionPath).ToString()).ToString();
            var repo = Path.Combine(sourceDirPath, "TestData", "sonar-doxygen");
            plugin.InitializeRepository(repo);
            var lineBlame = plugin.GetBlameByLine(Path.Combine(repo, "pom.xml"), 10);
            Assert.That(lineBlame, Is.Not.Null);
        }
Пример #6
0
        public void CorrectlyBlamesLineByCommandLineMultiple()
        {
            var lines = File.ReadLines(Path.Combine(this.executionPath, "data", "blameMultiple.txt")).ToList();

            var mockNote    = new Mock <INotificationManager>();
            var mockCommand = new Mock <IVSSonarQubeCmdExecutor>();

            mockCommand.Setup(x => x.GetStdOut()).Returns(lines);

            var plugin        = new SQGitPlugin(mockNote.Object, mockCommand.Object) as ISourceVersionPlugin;
            var sourceDirPath = Directory.GetParent(Directory.GetParent(this.executionPath).ToString()).ToString();
            var repo          = Path.Combine(sourceDirPath, "TestData", "sonar-doxygen");

            plugin.InitializeRepository(repo);
            var lineBlame = plugin.GetBlameByLine(Path.Combine(repo, "pom.xml"), 31);

            Assert.That(lineBlame, Is.Not.Null);
        }
Пример #7
0
 public void ThrowsForNotAvailableRepo()
 {
     var mockNote = new Mock<INotificationManager>();
     var plugin = new SQGitPlugin(mockNote.Object) as ISourceVersionPlugin;
     Assert.Throws<NullReferenceException>(() => plugin.InitializeRepository("c:\\windows"));
 }
Пример #8
0
 public void CorrectlyGetBranchIfNotRootRepo()
 {
     var mockNote = new Mock<INotificationManager>();
     var plugin = new SQGitPlugin(mockNote.Object) as ISourceVersionPlugin;
     var sourceDirPath = Directory.GetParent(Directory.GetParent(this.executionPath).ToString()).ToString();
     var repo = Path.Combine(sourceDirPath, "TestData", "sonar-doxygen", "src");
     plugin.InitializeRepository(repo);
     Assert.That(plugin.GetBranch(), Is.EqualTo("origin/master"));
 }