public void GivenAnEmptyCommitsList_CommitsCombinerShouldComplain_BecauseShouldAlwaysHasBaseAndHeadCommitsInIt() { Assert.Throws <ArgumentException>(() => { var x = new CommitsCombiner(new ObservableCollection <CommitVm>()); }); Assert.Throws <ArgumentException>(() => { // ReSharper disable once UnusedVariable var x = new CommitsCombiner(new ObservableCollection <CommitVm> { new CommitVm("BASE", "SHA"), }); }); Assert.DoesNotThrow(() => { // ReSharper disable once UnusedVariable var x = new CommitsCombiner(new ObservableCollection <CommitVm> { new CommitVm("BASE", "SHA"), new CommitVm("HEAD", "SHA"), }); }); }
public void CommitsCombinerShouldInsertNewCommitsBetweenBaseCommitAndHeadCommit() { var commits = new ObservableCollection <CommitVm>() { new CommitVm("BASE", "BASESHA"), new CommitVm("HEAD", "HEADSHA"), }; var combiner = new CommitsCombiner(commits); combiner.Add(new List <PullRequestCommit> { new PullRequestCommit(null, null, new Commit("URL", "Lable", "Ref", "SHA", null, null, "FirstCommit", null, null, null, new List <GitReference>(), 0), null, null, new List <GitReference>(), "FirstCommit SHA", null), new PullRequestCommit(null, null, new Commit("URL", "Lable", "Ref", "SHA", null, null, "SecondCommit", null, null, null, new List <GitReference>(), 0), null, null, new List <GitReference>(), "SecondCommit SHA", null), }); Assert.That(commits.Count, Is.EqualTo(4)); Assert.That(commits[0].WholeMessage, Is.EqualTo("BASE")); Assert.That(commits[1].WholeMessage, Is.EqualTo("FirstCommit")); Assert.That(commits[2].WholeMessage, Is.EqualTo("SecondCommit")); Assert.That(commits[3].WholeMessage, Is.EqualTo("HEAD")); Assert.That(commits[0].Sha, Is.EqualTo("BASESHA")); Assert.That(commits[1].Sha, Is.EqualTo("FirstCommit SHA")); Assert.That(commits[2].Sha, Is.EqualTo("SecondCommit SHA")); Assert.That(commits[3].Sha, Is.EqualTo("HEADSHA")); Assert.IsNotNullOrEmpty(commits[0].Display); Assert.IsNotNullOrEmpty(commits[1].Display); Assert.IsNotNullOrEmpty(commits[2].Display); Assert.IsNotNullOrEmpty(commits[3].Display); }