public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsNull_ReturnsOkObjectResultWhereValueIsNotNull() { Controller sut = CreateSut(false); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result; Assert.That(result.Value, Is.Not.Null); }
public async Task ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsValid_AssertPublishAsyncWasCalledOnCommandBusWithApplyPostingJournalCommand() { Controller sut = CreateSut(); await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel()); _commandBusMock.Verify(m => m.PublishAsync <IApplyPostingJournalCommand, IPostingJournalResult>(It.IsNotNull <IApplyPostingJournalCommand>()), Times.Once); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsActionResultWhereResultIsOkObjectResult() { Controller sut = CreateSut(); ActionResult <ApplyPostingJournalResultModel> result = await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel()); Assert.That(result.Result, Is.TypeOf <OkObjectResult>()); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsNotNull() { Controller sut = CreateSut(); ActionResult <ApplyPostingJournalResultModel> result = await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel()); Assert.That(result, Is.Not.Null); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsOkObjectResultWhereValueIsNotNull() { Controller sut = CreateSut(); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel())).Result; Assert.That(result.Value, Is.Not.Null); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModel() { Controller sut = CreateSut(); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result; Assert.That(result.Value, Is.TypeOf <ApplyPostingJournalResultModel>()); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsActionResultWhereResultIsNotNull() { Controller sut = CreateSut(); ActionResult <ApplyPostingJournalResultModel> result = await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel()); Assert.That(result.Result, Is.Not.Null); }
public async Task ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsValid_AssertPublishAsyncWasCalledOnCommandBusWithApplyPostingJournalCommandWherePostingLineCollectionIsNotNull() { Controller sut = CreateSut(); await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel()); _commandBusMock.Verify(m => m.PublishAsync <IApplyPostingJournalCommand, IPostingJournalResult>(It.Is <IApplyPostingJournalCommand>(command => command.PostingLineCollection != null)), Times.Once); }
public async Task ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsValid_AssertPublishAsyncWasCalledOnCommandBusWithApplyPostingJournalCommandWherePostingLineCollectionContainsMappedFromApplyPostingLineCollectionModel() { Controller sut = CreateSut(); ApplyPostingLineModel[] applyPostingLineModels = _fixture.CreateMany <ApplyPostingLineModel>(_random.Next(10, 15)).ToArray(); await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel(applyPostingLineModels)); _commandBusMock.Verify(m => m.PublishAsync <IApplyPostingJournalCommand, IPostingJournalResult>(It.Is <IApplyPostingJournalCommand>(command => command.PostingLineCollection.All(applyPostingLineCommand => applyPostingLineModels.Any(applyPostingLineModel => IsMatch(applyPostingLineCommand, applyPostingLineModel))))), Times.Once); }
public async Task ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsValid_AssertPublishAsyncWasCalledOnCommandBusWithApplyPostingJournalCommandWhereAccountingNumberIsEqualToAccountNumberFromApplyPostingJournalModel() { Controller sut = CreateSut(); int accountingNumber = _fixture.Create <int>(); await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel(accountingNumber)); _commandBusMock.Verify(m => m.PublishAsync <IApplyPostingJournalCommand, IPostingJournalResult>(It.Is <IApplyPostingJournalCommand>(command => command.AccountingNumber == accountingNumber)), Times.Once); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsNull_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModelWithPostingLinesNotEqualToNull() { Controller sut = CreateSut(false); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel())).Result; ApplyPostingJournalResultModel applyPostingJournalResultModel = (ApplyPostingJournalResultModel)result.Value; Assert.That(applyPostingJournalResultModel.PostingLines, Is.Not.Null); }
public async Task ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsValid_AssertPublishAsyncWasCalledOnCommandBusWithApplyPostingJournalCommandWherePostingLineCollectionHasSameAmountAsApplyPostingLinesFromApplyPostingJournalModel() { Controller sut = CreateSut(); ApplyPostingLineModel[] applyPostingLineModels = _fixture.CreateMany <ApplyPostingLineModel>(_random.Next(10, 15)).ToArray(); ApplyPostingLineCollectionModel applyPostingLineCollectionModel = CreateApplyPostingLineCollectionModel(applyPostingLineModels); await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel(applyPostingLineCollectionModel : applyPostingLineCollectionModel)); _commandBusMock.Verify(m => m.PublishAsync <IApplyPostingJournalCommand, IPostingJournalResult>(It.Is <IApplyPostingJournalCommand>(command => command.PostingLineCollection.Count() == applyPostingLineModels.Length)), Times.Once); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModelWithPostingWarningsNotEqualToNull() { Controller sut = CreateSut(); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result; ApplyPostingJournalResultModel applyPostingJournalResultModel = (ApplyPostingJournalResultModel)result.Value; Assert.That(applyPostingJournalResultModel.PostingWarnings, Is.Not.Null); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsNull_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModelWithEmptyPostingLines() { Controller sut = CreateSut(false); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result; ApplyPostingJournalResultModel applyPostingJournalResultModel = (ApplyPostingJournalResultModel)result.Value; Assert.That(applyPostingJournalResultModel.PostingLines, Is.Empty); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModelWherePostingWarningsContainsMappedPostingWarningsFromPostingJournalResult() { IPostingWarning[] postingWarnings = _fixture.CreateMany <IPostingWarning>(_random.Next(10, 25)).ToArray(); IPostingWarningCollection postingWarningCollection = _fixture.BuildPostingWarningCollectionMock(postingWarnings).Object; IPostingJournalResult postingJournalResult = _fixture.BuildPostingJournalResultMock(postingWarningCollection: postingWarningCollection).Object; Controller sut = CreateSut(postingJournalResult: postingJournalResult); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result; ApplyPostingJournalResultModel applyPostingJournalResultModel = (ApplyPostingJournalResultModel)result.Value; Assert.That(applyPostingJournalResultModel.PostingWarnings.All(postingWarningModel => postingWarnings.Any(postingWarning => IsMatch(postingWarningModel, postingWarning))), Is.True); }
public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModelWithSameAmountOfPostingWarningsAsPostingWarningsInPostingJournalResult() { IPostingWarning[] postingWarnings = _fixture.CreateMany <IPostingWarning>(_random.Next(10, 25)).ToArray(); IPostingWarningCollection postingWarningCollection = _fixture.BuildPostingWarningCollectionMock(postingWarnings).Object; IPostingJournalResult postingJournalResult = _fixture.BuildPostingJournalResultMock(postingWarningCollection: postingWarningCollection).Object; Controller sut = CreateSut(postingJournalResult: postingJournalResult); OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result; ApplyPostingJournalResultModel applyPostingJournalResultModel = (ApplyPostingJournalResultModel)result.Value; Assert.That(applyPostingJournalResultModel.PostingWarnings.Count, Is.EqualTo(postingWarnings.Length)); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsNull_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNull() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(null)); Assert.That(result, Is.Not.Null); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNull)); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsNull_ThrowsIntranetValidationException() { Controller sut = CreateSut(); Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(null)); }
public void ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsNull_ThrowsIntranetValidationException() { Controller sut = CreateSut(); Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), null)); }
public void ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsNull_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfApplyPostingLineCollectionModel() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), null)); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingType, Is.EqualTo(typeof(ApplyPostingLineCollectionModel))); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNull() { Controller sut = CreateSut(modelIsValid: false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); Assert.That(result, Is.Not.Null); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.SubmittedMessageInvalid)); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationExceptionWhereMessageContainsErrorMessage() { string errorMessage = _fixture.Create <string>(); Controller sut = CreateSut(modelIsValid: false, errorMessage: errorMessage); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); Assert.That(result, Is.Not.Null); Assert.That(result.Message, Is.Not.Null); Assert.That(result.Message.Contains(errorMessage), Is.True); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationExceptionWhereValidatingFieldIsNull() { Controller sut = CreateSut(modelIsValid: false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingField, Is.Null); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToApplyPostingJournal() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(null)); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingField, Is.EqualTo("applyPostingJournal")); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationException() { Controller sut = CreateSut(modelIsValid: false); Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); }
public void ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsInvalid_ThrowsIntranetValidationExceptionWhereValidatingTypeIsNull() { Controller sut = CreateSut(modelIsValid: false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel())); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingType, Is.Null); }