Ejemplo n.º 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"));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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"));
 }