Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsActionResultWhereResultIsOkObjectResult()
        {
            Controller sut = CreateSut();

            ActionResult <ApplyPostingJournalResultModel> result = await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel());

            Assert.That(result.Result, Is.TypeOf <OkObjectResult>());
        }
Beispiel #4
0
        public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            ActionResult <ApplyPostingJournalResultModel> result = await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel());

            Assert.That(result, Is.Not.Null);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        public async Task ApplyPostingJournalAsync_WhenPublishAsyncForApplyPostingJournalCommandReturnsPostingJournalResult_ReturnsOkObjectResultWhereValueIsApplyPostingJournalResultModel()
        {
            Controller sut = CreateSut();

            OkObjectResult result = (OkObjectResult)(await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())).Result;

            Assert.That(result.Value, Is.TypeOf <ApplyPostingJournalResultModel>());
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        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));
        }
Beispiel #17
0
        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));
        }
Beispiel #18
0
        public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsNull_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut();

            Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(null));
        }
Beispiel #19
0
        public void ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsNull_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut();

            Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), null));
        }
Beispiel #20
0
        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)));
        }
Beispiel #21
0
        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));
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        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);
        }
Beispiel #24
0
        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"));
        }
Beispiel #25
0
        public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut(modelIsValid: false);

            Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel()));
        }
Beispiel #26
0
        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);
        }