public void Ordered_WhenPostingLineCollectionHasPostingLines_ReturnsPostingLineCollectionWithOrderedPostingLines() { IPostingLineCollection sut = CreateSut(); sut.Add(_fixture.CreateMany <IPostingLine>(_random.Next(10, 25))); IPostingLineCollection result = sut.Ordered(); IPostingLine[] postingLines = result.ToArray(); for (int i = 1; i < postingLines.Length; i++) { Assert.That(postingLines[i].PostingDate, Is.LessThanOrEqualTo(postingLines[i - 1].PostingDate)); if (postingLines[i].PostingDate.Date != postingLines[i - 1].PostingDate.Date) { continue; } Assert.That(postingLines[i].SortOrder, Is.LessThanOrEqualTo(postingLines[i - 1].SortOrder)); } }
public void Top_WhenPostingLineCollectionContainsPostingLinesMoreThanOfPostingLines_ReturnsPostingLineCollectionWithOrderedPostingLines() { IPostingLineCollection sut = CreateSut(); int numberOfPostingLines = _random.Next(10, 25); sut.Add(_fixture.CreateMany <IPostingLine>(numberOfPostingLines + _random.Next(1, 10))); IPostingLineCollection result = sut.Top(numberOfPostingLines); IPostingLine[] postingLines = result.ToArray(); for (int i = 1; i < postingLines.Length; i++) { Assert.That(postingLines[i].PostingDate, Is.LessThanOrEqualTo(postingLines[i - 1].PostingDate)); if (postingLines[i].PostingDate.Date == postingLines[i - 1].PostingDate.Date) { Assert.That(postingLines[i].SortOrder, Is.LessThanOrEqualTo(postingLines[i - 1].SortOrder)); } } }