public async Task ExecuteAsync_WhenPostingJournalResultWasReturnedFromAccountingRepository_ReturnsNotNull() { CommandHandler sut = CreateSut(); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); IPostingJournalResult result = await sut.ExecuteAsync(applyPostingJournalCommand); Assert.That(result, Is.Not.Null); }
public async Task ExecuteAsync_WhenNoPostingJournalResultWasReturnedFromAccountingRepository_AssertCalculateAsyncWasCalledOnPostingWarningCalculatorWithEmptyPostingLineCollection() { CommandHandler sut = CreateSut(false); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); await sut.ExecuteAsync(applyPostingJournalCommand); _postingWarningCalculatorMock.Verify(m => m.CalculateAsync(It.Is <IPostingLineCollection>(value => value != null && value.Any() == false)), Times.Once); }
public async Task ExecuteAsync_WhenCalled_AssertToDomainWasCalledOnApplyPostingJournalCommand() { CommandHandler sut = CreateSut(); Mock <IApplyPostingJournalCommand> applyPostingJournalCommandMock = CreateApplyPostingJournalCommandMock(); await sut.ExecuteAsync(applyPostingJournalCommandMock.Object); applyPostingJournalCommandMock.Verify(m => m.ToDomain(It.Is <IAccountingRepository>(value => value == _accountingRepositoryMock.Object)), Times.Once); }
public async Task ExecuteAsync_WhenNoPostingJournalResultWasReturnedFromAccountingRepository_ReturnsCalculatedPostingJournalResult() { CommandHandler sut = CreateSut(false); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); IPostingJournalResult result = await sut.ExecuteAsync(applyPostingJournalCommand); Assert.That(result.StatusDate, Is.EqualTo(DateTime.Today)); }
public async Task ExecuteAsync_WhenNoPostingJournalResultWasReturnedFromAccountingRepository_ReturnsPostingJournalResultWherePostingWarningCollectionIsNotNull() { CommandHandler sut = CreateSut(false); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); IPostingJournalResult result = await sut.ExecuteAsync(applyPostingJournalCommand); Assert.That(result.PostingWarningCollection, Is.Not.Null); }
public async Task ExecuteAsync_WhenNoPostingJournalResultWasReturnedFromAccountingRepository_ReturnsPostingJournalResult() { CommandHandler sut = CreateSut(false); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); IPostingJournalResult result = await sut.ExecuteAsync(applyPostingJournalCommand); Assert.That(result, Is.TypeOf <PostingJournalResult>()); }
public void ExecuteAsync_WhenApplyPostingJournalCommandIsNull_ThrowsArgumentNullException() { CommandHandler sut = CreateSut(); ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.ExecuteAsync(null)); // ReSharper disable PossibleNullReferenceException Assert.That(result.ParamName, Is.EqualTo("applyPostingJournalCommand")); // ReSharper restore PossibleNullReferenceException }
public async Task ExecuteAsync_WhenPostingJournalResultWasReturnedFromAccountingRepository_AssertCalculateAsyncWasCalledOnPostingJournalResultFromAccountingRepository() { Mock <IPostingJournalResult> postingJournalResultMock = _fixture.BuildPostingJournalResultMock(); CommandHandler sut = CreateSut(postingJournalResult: postingJournalResultMock.Object); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); await sut.ExecuteAsync(applyPostingJournalCommand); postingJournalResultMock.Verify(m => m.CalculateAsync(It.Is <DateTime>(value => value == DateTime.Today)), Times.Once); }
public async Task ExecuteAsync_WhenNoPostingJournalResultWasReturnedFromAccountingRepository_ReturnsPostingJournalResultWherePostingWarningCollectionEqualToPostingWarningCollectionFromPostingWarningCalculator() { IPostingWarningCollection postingWarningCollection = _fixture.BuildPostingWarningCollectionMock(isEmpty: true).Object; CommandHandler sut = CreateSut(false, postingWarningCollection: postingWarningCollection); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); IPostingJournalResult result = await sut.ExecuteAsync(applyPostingJournalCommand); Assert.That(result.PostingWarningCollection, Is.EqualTo(postingWarningCollection)); }
public async Task ExecuteAsync_WhenPostingJournalResultWasReturnedFromAccountingRepository_ReturnsCalculatedPostingJournalResult() { IPostingJournalResult calculatedPostingJournalResult = _fixture.BuildPostingJournalResultMock().Object; IPostingJournalResult postingJournalResult = _fixture.BuildPostingJournalResultMock(calculatedPostingJournalResult: calculatedPostingJournalResult).Object; CommandHandler sut = CreateSut(postingJournalResult: postingJournalResult); IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(); IPostingJournalResult result = await sut.ExecuteAsync(applyPostingJournalCommand); Assert.That(result, Is.EqualTo(calculatedPostingJournalResult)); }
public async Task ExecuteAsync_WhenCalled_AssertApplyPostingJournalAsyncWasCalledOnAccountingRepository() { CommandHandler sut = CreateSut(); IPostingJournal postingJournal = _fixture.BuildPostingJournalMock().Object; IApplyPostingJournalCommand applyPostingJournalCommand = CreateApplyPostingJournalCommand(postingJournal); await sut.ExecuteAsync(applyPostingJournalCommand); _accountingRepositoryMock.Verify(m => m.ApplyPostingJournalAsync( It.Is <IPostingJournal>(value => value == postingJournal), It.Is <IPostingWarningCalculator>(value => value == _postingWarningCalculatorMock.Object)), Times.Once); }