Example #1
0
        public async Task Run_adds_all_commits_if_no_previous_version_exists()
        {
            // ARRANGE
            var repo = new Mock <IGitRepository>(MockBehavior.Strict);

            repo
            .Setup(x => x.GetCommits(null, It.IsAny <GitId>()))
            .Returns(new[]
            {
                GetGitCommit(TestGitIds.Id1, "Commit 1"),
                GetGitCommit(TestGitIds.Id2, "Commit 2")
            });

            var sut = new LoadCommitsTask(m_Logger, repo.Object);

            var versionChangeLog = GetSingleVersionChangeLog("1.2.3", TestGitIds.Id1);
            var changelog        = new ApplicationChangeLog()
            {
                versionChangeLog
            };

            // ACT
            var result = await sut.RunAsync(changelog);

            // ASSERT
            Assert.Equal(ChangeLogTaskResult.Success, result);

            repo.Verify(x => x.GetCommits(It.IsAny <GitId?>(), It.IsAny <GitId>()), Times.Once);

            Assert.NotNull(versionChangeLog.AllCommits);
            Assert.Equal(2, versionChangeLog.AllCommits.Count);
            Assert.Contains(versionChangeLog.AllCommits, c => c.Id == TestGitIds.Id1);
            Assert.Contains(versionChangeLog.AllCommits, c => c.Id == TestGitIds.Id2);
        }
Example #2
0
        public async Task Run_does_nothing_for_empty_changelog()
        {
            // ARRANGE
            var repo = Mock.Of <IGitRepository>(MockBehavior.Strict);

            var sut = new LoadCommitsTask(m_Logger, repo);

            // ACT
            var changelog = new ApplicationChangeLog();
            var result    = await sut.RunAsync(changelog);

            // ASSERT
            Assert.Equal(ChangeLogTaskResult.Skipped, result);
        }