public async Task GetPostingLinesAsync_WhenCalledOnAccountWithNonEmptyAccountCollection_ReturnsPostingLineCollectionWithPostingLinesUpToStatusDate()
        {
            DateTime     statusDate = DateTime.Today.AddDays(_random.Next(1, 7) * -1);
            IPostingLine postingLine1BeforeStatusDate = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7) * -1)).Object;
            IPostingLine postingLine2BeforeStatusDate = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7) * -1)).Object;
            IPostingLine postingLine3BeforeStatusDate = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7) * -1)).Object;
            IPostingLine postingLine1OnStatusDate     = _fixture.BuildPostingLineMock(postingDate: statusDate).Object;
            IPostingLine postingLine2OnStatusDate     = _fixture.BuildPostingLineMock(postingDate: statusDate).Object;
            IPostingLine postingLine3OnStatusDate     = _fixture.BuildPostingLineMock(postingDate: statusDate).Object;
            IPostingLine postingLine1AfterStatusDate  = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7))).Object;
            IPostingLine postingLine2AfterStatusDate  = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7))).Object;
            IPostingLine postingLine3AfterStatusDate  = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7))).Object;

            IAccount[] accountCollection =
            {
                _fixture.BuildAccountMock(postingLineCollection: _fixture.BuildPostingLineCollectionMock(postingLineCollection: new[] { postingLine1BeforeStatusDate, postingLine1OnStatusDate, postingLine1AfterStatusDate }).Object).Object,
                _fixture.BuildAccountMock(postingLineCollection: _fixture.BuildPostingLineCollectionMock(postingLineCollection: new[] { postingLine2BeforeStatusDate, postingLine2OnStatusDate, postingLine2AfterStatusDate }).Object).Object,
                _fixture.BuildAccountMock(postingLineCollection: _fixture.BuildPostingLineCollectionMock(postingLineCollection: new[] { postingLine3BeforeStatusDate, postingLine3OnStatusDate, postingLine3AfterStatusDate }).Object).Object
            };
            IAccounting sut = CreateSut(accountCollection);

            IPostingLineCollection result = await sut.GetPostingLinesAsync(statusDate);

            Assert.That(result.Contains(postingLine1BeforeStatusDate), Is.True);
            Assert.That(result.Contains(postingLine2BeforeStatusDate), Is.True);
            Assert.That(result.Contains(postingLine3BeforeStatusDate), Is.True);
            Assert.That(result.Contains(postingLine1OnStatusDate), Is.True);
            Assert.That(result.Contains(postingLine2OnStatusDate), Is.True);
            Assert.That(result.Contains(postingLine3OnStatusDate), Is.True);
            Assert.That(result.Contains(postingLine1AfterStatusDate), Is.False);
            Assert.That(result.Contains(postingLine2AfterStatusDate), Is.False);
            Assert.That(result.Contains(postingLine3AfterStatusDate), Is.False);
        }
Example #2
0
        public void Add_WhenPostingLineIsNotNullAndDoesNotExistWithinCollection_AddsPostingLineToCollection()
        {
            IPostingLineCollection sut = CreateSut();

            IPostingLine postingLine = _fixture.BuildPostingLineMock().Object;

            sut.Add(postingLine);

            Assert.That(sut.Contains(postingLine), Is.True);
        }
        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 Top_WhenPostingLineCollectionContainsPostingLinesMoreThanNumberOfPostingLines_ReturnsPostingLineCollectionWithPostingLinesFromPostingLinesCollection()
        {
            IPostingLineCollection sut = CreateSut();

            int numberOfPostingLines = _random.Next(10, 25);

            sut.Add(_fixture.CreateMany <IPostingLine>(numberOfPostingLines + _random.Next(1, 10)));

            IPostingLineCollection result = sut.Top(numberOfPostingLines);

            foreach (IPostingLine postingLine in result)
            {
                Assert.That(sut.Contains(postingLine), Is.True);
            }
        }
        public void Top_WhenPostingLineCollectionContainsPostingLinesEqualToNumberOfPostingLines_ReturnsPostingLineCollectionWithSamePostingLines()
        {
            IPostingLineCollection sut = CreateSut();

            int numberOfPostingLines = _random.Next(10, 25);

            IPostingLine[] postingLines = _fixture.CreateMany <IPostingLine>(numberOfPostingLines).ToArray();
            sut.Add(postingLines);

            IPostingLineCollection result = sut.Top(numberOfPostingLines);

            foreach (IPostingLine postingLine in postingLines)
            {
                Assert.That(result.Contains(postingLine), Is.True);
            }
        }
Example #6
0
        public void Add_WhenPostingLineCollectionIsNotNullAndEachPostingLineDoesNotExistWithinCollection_AddsEachPostingLineToCollection()
        {
            IPostingLineCollection sut = CreateSut();

            IEnumerable <IPostingLine> postingLineCollection = new List <IPostingLine>
            {
                _fixture.BuildPostingLineMock().Object,
                                       _fixture.BuildPostingLineMock().Object,
                                       _fixture.BuildPostingLineMock().Object,
                                       _fixture.BuildPostingLineMock().Object,
                                       _fixture.BuildPostingLineMock().Object,
                                       _fixture.BuildPostingLineMock().Object,
                                       _fixture.BuildPostingLineMock().Object
            };

            sut.Add(postingLineCollection);

            Assert.That(postingLineCollection.All(account => sut.Contains(account)), Is.True);
        }
        public void Top_WhenPostingLineCollectionContainsPostingLinesMoreThanOfPostingLines_ReturnsPostingLineCollectionWithTopPostingLinesFromPostingLineCollection()
        {
            IPostingLineCollection sut = CreateSut();

            DateTime     maxDate = DateTime.Today.AddDays(_random.Next(1, 7) * -1);
            IPostingLine postingLineNotWithinTop1   = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(7, 30) * -1)).Object;
            IPostingLine postingLineNotWithinTop2   = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(7, 30) * -1)).Object;
            IPostingLine postingLineNotWithinTop3   = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(7, 30) * -1)).Object;
            IPostingLine postingLineNotWithinTop4   = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(7, 30) * -1)).Object;
            IPostingLine postingLineNotWithinTop5   = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(7, 30) * -1)).Object;
            IPostingLine postingLineWithinTop1      = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(0, 7) * -1)).Object;
            IPostingLine postingLineWithinTop2      = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(0, 6) * -1)).Object;
            IPostingLine postingLineWithinTop3      = _fixture.BuildPostingLineMock(postingDate: maxDate.AddDays(_random.Next(0, 6) * -1)).Object;
            IEnumerable <IPostingLine> postingLines = new List <IPostingLine>
            {
                postingLineNotWithinTop1,
                postingLineNotWithinTop2,
                postingLineNotWithinTop3,
                postingLineNotWithinTop4,
                postingLineNotWithinTop5,
                postingLineWithinTop1,
                postingLineWithinTop2,
                postingLineWithinTop3
            };

            sut.Add(postingLines);

            IPostingLineCollection result = sut.Top(3);

            Assert.That(result.Contains(postingLineNotWithinTop1), Is.False);
            Assert.That(result.Contains(postingLineNotWithinTop2), Is.False);
            Assert.That(result.Contains(postingLineNotWithinTop3), Is.False);
            Assert.That(result.Contains(postingLineNotWithinTop4), Is.False);
            Assert.That(result.Contains(postingLineNotWithinTop5), Is.False);
            Assert.That(result.Contains(postingLineWithinTop1), Is.True);
            Assert.That(result.Contains(postingLineWithinTop2), Is.True);
            Assert.That(result.Contains(postingLineWithinTop3), Is.True);
        }