public void InitsDbOnPrinting() { var db = new FakeDatabase(); var diff = new FakeDiff( "key", "start", "end", null, "author", "org", 10u, new[] { new DefaultDeletion("victim1", 7u), new DefaultDeletion("victim2", 14u), }, DateTimeOffset.UtcNow ); var app = new ConsoleApplication(db, new EloFormula()); app.Save(diff); app.PrintTo(new FakeOutput(new List <string>()), diff); Assert.True(db.Instance().Present()); }
public void ShowsDiff() { var lines = new List <string>(); var deletions = new[] { new DefaultDeletion("victim1", 7u), new DefaultDeletion("victim2", 14u), }; var diff = new FakeDiff( "key", "start", "end", null, "author", "org", 10u, deletions, DateTimeOffset.UtcNow ); var app = new ConsoleApplication(new FakeDatabase(), new EloFormula()); app.Save(diff); app.PrintTo(new FakeOutput(lines), diff); Assert.Equal(deletions.Length, lines.Count(l => l.Contains("victim"))); }
public void PrintsLinkOfWork() { var lines = new List <string>(); var diff = new FakeDiff("E.g. a link to the PR"); var app = new ConsoleApplication(new FakeDatabase(), new EloFormula()); app.Save(diff); app.PrintTo(new FakeOutput(lines), diff); Assert.Contains(lines, p => p.Equals("Link: E.g. a link to the PR")); }
public void PrintsSinceCommitOfWork() { var lines = new List <string>(); var diff = new FakeDiff(); var app = new ConsoleApplication(new FakeDatabase(), new EloFormula()); app.Save(diff); app.PrintTo(new FakeOutput(lines), diff); Assert.Contains(lines, p => p.Equals("Since: since this commit")); }
public void ThrowsExceptionIfDiffAlreadySaved() { var authors = new List <Author>(); var works = new List <Work>(); var ratings = new List <Rating>(); var diff = new FakeDiff( "key", "start", "end", null, "author", "org", 10u, new[] { new DefaultDeletion("victim1", 7u), new DefaultDeletion("victim2", 14u), }, DateTimeOffset.UtcNow ); var application = new ConsoleApplication( new FakeDatabase( new FakeDbInstance(), new FakeEntities( new FakeWorks(ratings, works, authors), new FakeRatings(ratings, works, authors), new FakeAuthors(authors) ) ), new EloFormula() ); application.Save(diff); void TestCode() { application !.Save(diff !); } Assert.Throws <InvalidOperationException>(TestCode); }