public void Ordered_WhenPostingLineCollectionIsEmpty_ReturnsEmptyPostingLineCollection() { IPostingLineCollection sut = CreateSut(); IPostingLineCollection result = sut.Ordered(); Assert.That(result, Is.Empty); }
public void Ordered_WhenCalled_ReturnsPostingLineCollection() { IPostingLineCollection sut = CreateSut(); sut.Add(_fixture.CreateMany <IPostingLine>(_random.Next(10, 25)).ToArray()); IPostingLineCollection result = sut.Ordered(); Assert.That(result, Is.TypeOf <Domain.Accounting.PostingLineCollection>()); }
public void Ordered_WhenCalled_ReturnsNotNull() { IPostingLineCollection sut = CreateSut(); sut.Add(_fixture.CreateMany <IPostingLine>(_random.Next(10, 25)).ToArray()); IPostingLineCollection result = sut.Ordered(); Assert.That(result, Is.Not.Null); }
public void Ordered_WhenPostingLineCollectionHasPostingLines_ReturnsPostingLineCollectionWithSameAmountOfPostingLines() { IPostingLineCollection sut = CreateSut(); IPostingLine[] postingLines = _fixture.CreateMany <IPostingLine>(_random.Next(10, 25)).ToArray(); sut.Add(postingLines); IPostingLineCollection result = sut.Ordered(); Assert.That(result.Count(), Is.EqualTo(postingLines.Length)); }
public void Ordered_WhenPostingLineCollectionHasPostingLines_ReturnsPostingLineCollectionWithSamePostingLines() { IPostingLineCollection sut = CreateSut(); IPostingLine[] postingLines = _fixture.CreateMany <IPostingLine>(_random.Next(10, 25)).ToArray(); sut.Add(postingLines); IPostingLineCollection result = sut.Ordered(); foreach (IPostingLine postingLine in postingLines) { Assert.That(result.Contains(postingLine), Is.True); } }
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 Ordered_WhenCalled_AssertSortOrderWasCalledOnEachPostingLine() { IPostingLineCollection sut = CreateSut(); IEnumerable <Mock <IPostingLine> > postingLineMockCollection = new List <Mock <IPostingLine> > { _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)), _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)), _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)), _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)), _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)), _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)), _fixture.BuildPostingLineMock(postingDate: DateTime.Today.AddDays(_random.Next(0, 30) * -1), sortOrder: _random.Next(100)) }; sut.Add(postingLineMockCollection.Select(postingLineMock => postingLineMock.Object)); sut.Ordered(); foreach (Mock <IPostingLine> postingLineMock in postingLineMockCollection) { postingLineMock.Verify(m => m.SortOrder, Times.Once); } }