示例#1
0
        public void GetGitHubUsername_NotAUrl()
        {
            string url          = @"asdfasdf";
            string expectedUser = null;
            string actualUser   = GetCommitInfo.GetGitHubUser(url);

            Assert.AreEqual(expectedUser, actualUser);
        }
示例#2
0
        public void GetGitHubUsername_NoUser()
        {
            string url          = @"https://github.com/";
            string expectedUser = null;
            string actualUser   = GetCommitInfo.GetGitHubUser(url);

            Assert.AreEqual(expectedUser, actualUser);
        }
示例#3
0
        public void GetGitHubUsername_NotGithub()
        {
            string url          = @"https://gitlab.com/Zingabopp/BeatSaberModdingTools.Tasks";
            string expectedUser = null;
            string actualUser   = GetCommitInfo.GetGitHubUser(url);

            Assert.AreEqual(expectedUser, actualUser);
        }
示例#4
0
        public void TryGetCommitHash_Test()
        {
            string     directory = Environment.CurrentDirectory;
            IGitRunner gitRunner = new GitCommandRunner(directory);
            bool       success   = GetCommitInfo.TryGetGitCommit(gitRunner, null, out string commitHash);

            Assert.IsTrue(success);
            Assert.IsTrue(commitHash.Length > 0);
        }
示例#5
0
        public void GetGitStatus_Test()
        {
            string     directory    = Environment.CurrentDirectory;
            IGitRunner gitRunner    = new GitCommandRunner(directory);
            string     expectedUser = "******";
            GitInfo    status       = GetCommitInfo.GetGitStatus(gitRunner, null);

            Assert.IsFalse(string.IsNullOrEmpty(status.Branch), $"Branch should not be null/empty.");
            Assert.IsFalse(string.IsNullOrEmpty(status.Modified));
            Assert.IsTrue(status.Modified == "Unmodified" || status.Modified == "Modified");
            Assert.AreEqual(expectedUser, status.GitUser);
        }
示例#6
0
        public void TryGetCommitManual_Test()
        {
            string directory      = Path.Combine(DataFolder, "GitTests", "Test.git");
            string expectedBranch = "master";
            string expectedHash   = "4197466ed7682542b4669e98fd962a3925ccaadf";
            string expectedUrl    = @"https://github.com/Zingabopp/BeatSaberModdingTools.Tasks";
            string expectedUser   = "******";

            Assert.IsTrue(GetCommitInfo.TryGetCommitManual(directory, out GitInfo gitInfo));
            Assert.AreEqual(expectedBranch, gitInfo.Branch);
            Assert.AreEqual(expectedHash, gitInfo.CommitHash);
            Assert.AreEqual(expectedUrl, gitInfo.OriginUrl);
            Assert.AreEqual(expectedUser, gitInfo.GitUser);
        }
示例#7
0
        public void GetGitStatus_Test()
        {
            string     directory = Environment.CurrentDirectory;
            IGitRunner gitRunner = new GitCommandRunner(directory);
            //string expectedUser = "******";
            MockTaskLogger logger     = new MockTaskLogger("GitCommandRunner");
            GitInfo        status     = GetCommitInfo.GetGitStatus(gitRunner, logger);
            string         logEntries = string.Join('\n', logger.LogEntries.Select(e => e.ToString()));

            Assert.IsFalse(string.IsNullOrEmpty(status.Branch), $"Branch should not be null/empty.\n{logEntries}");
            Assert.IsFalse(string.IsNullOrEmpty(status.Modified), $"'Modified' should not be null/empty.\n{logEntries}");
            Assert.IsTrue(status.Modified == "Unmodified" || status.Modified == "Modified", $"'Modified' has an unrecognized value.\n{logEntries}");
            Assert.IsFalse(string.IsNullOrWhiteSpace(status.GitUser), $"GitUser should not be null/empty.\n{logEntries}");
            //Assert.AreEqual(expectedUser, status.GitUser);
        }