Esempio n. 1
0
        public override bool Equals(RepositoryCommit other)
        {
            if (!(other is SvnRepositoryCommit svnCommit))
            {
                return(false);
            }

            return(string.Equals(this.Revision, svnCommit.Revision, StringComparison.OrdinalIgnoreCase));
        }
        public override bool Equals(RepositoryCommit other)
        {
            if (!(other is GitRepositoryCommit gitCommit))
            {
                return(false);
            }

            return(string.Equals(this.Hash, gitCommit.Hash, StringComparison.OrdinalIgnoreCase));
        }
        public void Should_CreateRepositoryCommit()
        {
            //arrange
            string name        = "a name";
            string description = "some content";
            string websiteUrl  = "https://example.com/";
            User   user1       = new User()
            {
                FirstName  = "Patrick",
                MiddleName = "van",
                LastName   = "Batenburg",
                Email      = "*****@*****.**"
            };
            RepositoryBranch branch = new RepositoryBranch()
            {
                Name = "master"
            };
            RepositoryCommit commit = new RepositoryCommit()
            {
                Author  = user1,
                Message = "init commit",
                Branch  = branch
            };

            commit.Size = Encoding.ASCII.GetBytes(commit.Message).ToString();

            Mock <Repository> repository = new Mock <Repository>()
            {
                CallBase = true
            };

            //act
            branch.Add(commit);

            repository.Object.Name          = name;
            repository.Object.Description   = description;
            repository.Object.WebsiteUrl    = websiteUrl;
            repository.Object.DefaultBranch = branch;
            repository.Object.Type          = RepositoryType.SVN;

            //assert
            Assert.Equal(name, repository.Object.Name);
            Assert.Equal(description, repository.Object.Description);
            Assert.Equal(websiteUrl, repository.Object.WebsiteUrl);
            Assert.Equal(branch, repository.Object.DefaultBranch);
            Assert.Equal(commit, branch.Commits[0]);
            Assert.Single(branch.Commits);
            Assert.Equal(RepositoryType.SVN, repository.Object.Type);
        }