public void VerifyUnparseableAreSkipped()
        {
            var today      = DateTimeOffset.Now;
            var yesterday  = DateTimeOffset.Now.AddDays(-1);
            var twoDaysAgo = DateTimeOffset.Now.AddDays(-2);
            var changes    = new List <IChange>
            {
                new DefaultChange("0.2.0", " ", "Without tag", today),
                new DefaultChange(" ", "Added", "WithoutVersion", yesterday),
                new DefaultChange("0.1.0", "Removed", "Another Summary", twoDaysAgo)
            };
            var expectedChanges = new List <IChange>
            {
                new DefaultChange("0.1.0", "Removed", "Another Summary", twoDaysAgo)
            };
            var repoMock   = new Mock <IRepository>();
            var commitLog  = Mock.Of <IQueryableCommitLog>(cl => cl.GetEnumerator() == MockCommitEnumerator(changes));
            var parserMock = new Mock <ICommitParser <IChange> >();
            var reader     = new GitReader <IChange>(repoMock.Object, parserMock.Object);

            parserMock.SetupSequence(p => p.Parse(It.IsAny <Commit>()))
            .Returns((IChange)null)
            .Returns((IChange)null)
            .Returns(expectedChanges.First);

            repoMock.Setup(r => r.Commits).Returns(commitLog);
            var actualChanges = reader.Values().ToList();

            Assert.That(actualChanges, Is.EquivalentTo(expectedChanges));
            repoMock.VerifyAll();
        }
        public void VerifyOverriddenChangesAreUsed()
        {
            var yesterday   = DateTimeOffset.Now.AddDays(-1);
            var twoDaysAgo  = DateTimeOffset.Now.AddDays(-2);
            var badChange   = new DefaultChange(" ", "Added", "WithoutVersion", yesterday);
            var fixedChange = new DefaultChange("0.2.0", badChange.Tag, badChange.Summary, badChange.Date);
            var fineChange  = new DefaultChange("0.1.0", "Removed", "Another Summary", twoDaysAgo);
            var overrides   = new Dictionary <string, IChange>
            {
                { ToSha1String(badChange), fixedChange }
            };
            var changes = new List <IChange>
            {
                badChange,
                fineChange
            };
            var expectedChanges = new List <IChange>
            {
                fixedChange,
                fineChange
            };
            var repoMock   = new Mock <IRepository>();
            var commitLog  = Mock.Of <IQueryableCommitLog>(cl => cl.GetEnumerator() == MockCommitEnumerator(changes));
            var parserMock = new Mock <ICommitParser <IChange> >();

            parserMock.Setup(p => p.Parse(fixedChange)).Returns(fixedChange);
            parserMock.Setup(p => p.Parse(It.IsAny <Commit>())).Returns(fineChange);
            repoMock.Setup(r => r.Commits).Returns(commitLog);

            var reader        = new GitReader <IChange>(repoMock.Object, parserMock.Object, overrides);
            var actualChanges = reader.Values();

            Assert.That(actualChanges, Is.EquivalentTo(expectedChanges));
            repoMock.VerifyAll();
        }
        public void VerifyReaderReadsFromRepository()
        {
            var expectedChanges = new List <IChange>
            {
                new DefaultChange("0.2.0", "Added", "Some Summary", DateTimeOffset.Now),
                new DefaultChange("0.1.0", "Removed", "Another Summary", DateTimeOffset.Now.AddDays(-1))
            };
            var repoMock   = new Mock <IRepository>();
            var commitLog  = Mock.Of <IQueryableCommitLog>(cl => cl.GetEnumerator() == MockCommitEnumerator(expectedChanges));
            var parserMock = new Mock <ICommitParser <IChange> >();
            var reader     = new GitReader <IChange>(repoMock.Object, parserMock.Object);

            repoMock.Setup(r => r.Commits).Returns(commitLog);
            foreach (var expectedChange in expectedChanges)
            {
                parserMock.Setup(p => p.Parse(It.Is <Commit>(c => c.Id.Sha == ToSha1String(expectedChange)))).Returns(expectedChange);
            }

            Assert.That(reader.Values(), Is.EquivalentTo(expectedChanges));
            repoMock.VerifyAll();
        }