public void ThrowsForNotAvailableRepo() { var mockNote = new Mock <INotificationManager>(); var plugin = new SQGitPlugin(mockNote.Object) as ISourceVersionPlugin; Assert.Throws <NullReferenceException>(() => plugin.InitializeRepository("c:\\windows")); }
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")); }
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); }
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); }
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); }
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); }
public void ThrowsForNotAvailableRepo() { var mockNote = new Mock<INotificationManager>(); var plugin = new SQGitPlugin(mockNote.Object) as ISourceVersionPlugin; Assert.Throws<NullReferenceException>(() => plugin.InitializeRepository("c:\\windows")); }
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")); }