public async Task CalculateAsync_WhenCalled_ReturnsSamePostingJournalResult()
        {
            IPostingJournalResult sut = CreateSut();

            IPostingJournalResult result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result, Is.SameAs(sut));
        }
        public async Task CalculateAsync_WhenCalled_ReturnsSamePostingJournalResultWherePostingWarningCollectionIsEqualToPostingWarningCollectionFromPostingWarningCalculator()
        {
            IPostingWarningCollection postingWarningCollection = _fixture.BuildPostingWarningCollectionMock().Object;
            IPostingWarningCalculator postingWarningCalculator = _fixture.BuildPostingWarningCalculatorMock(postingWarningCollection).Object;
            IPostingJournalResult     sut = CreateSut(postingWarningCalculator: postingWarningCalculator);

            IPostingJournalResult result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result.PostingWarningCollection, Is.SameAs(postingWarningCollection));
        }
        public async Task CalculateAsync_WhenCalled_ReturnsSamePostingJournalResultWherePostingLineCollectionIsEqualToCalculatedPostingLineCollection()
        {
            IPostingLineCollection calculatedPostingLineCollection = _fixture.BuildPostingLineCollectionMock(isEmpty: true).Object;
            IPostingLineCollection postingLineCollection           = _fixture.BuildPostingLineCollectionMock(calculatedPostingLineCollection: calculatedPostingLineCollection, isEmpty: true).Object;
            IPostingJournalResult  sut = CreateSut(postingLineCollection);

            IPostingJournalResult result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result.PostingLineCollection, Is.SameAs(calculatedPostingLineCollection));
        }
        public async Task CalculateAsync_WhenCalled_AssertCalculateAsyncWasCalledOnPostingLineCollection()
        {
            Mock <IPostingLineCollection> postingLineCollectionMock = _fixture.BuildPostingLineCollectionMock(isEmpty: true);
            IPostingJournalResult         sut = CreateSut(postingLineCollectionMock.Object);

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            await sut.CalculateAsync(statusDate);

            postingLineCollectionMock.Verify(m => m.CalculateAsync(It.Is <DateTime>(value => value == statusDate.Date)), Times.Once);
        }
        public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_AssertCalculateAsyncWasCalledOnlyOnceOnPostingWarningCalculatorWithCalculatedPostingLineCollection()
        {
            IPostingLineCollection           calculatedPostingLineCollection = _fixture.BuildPostingLineCollectionMock(isEmpty: true).Object;
            IPostingLineCollection           postingLineCollection           = _fixture.BuildPostingLineCollectionMock(calculatedPostingLineCollection: calculatedPostingLineCollection, isEmpty: true).Object;
            Mock <IPostingWarningCalculator> postingWarningCalculatorMock    = _fixture.BuildPostingWarningCalculatorMock(isEmpty: true);
            IPostingJournalResult            sut = CreateSut(postingLineCollection, postingWarningCalculatorMock.Object);

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);

            await(await(await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate);

            postingWarningCalculatorMock.Verify(m => m.CalculateAsync(It.Is <IPostingLineCollection>(value => value == calculatedPostingLineCollection)), Times.Once);
        }