Exemple #1
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithSortedApplyPostingLines()
        {
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>());
            ApplyPostingJournalViewModel savedApplyPostingJournalViewModel = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(savedApplyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            for (int i = 1; i < applyPostingJournalViewModel.ApplyPostingLines.Count; i++)
            {
                Assert.That(applyPostingJournalViewModel.ApplyPostingLines[i].PostingDate.UtcDateTime.Date, Is.LessThanOrEqualTo(applyPostingJournalViewModel.ApplyPostingLines[i - 1].PostingDate.UtcDateTime.Date));
                if (applyPostingJournalViewModel.ApplyPostingLines[i].PostingDate.UtcDateTime.Date != applyPostingJournalViewModel.ApplyPostingLines[i - 1].PostingDate.UtcDateTime.Date)
                {
                    continue;
                }

                Assert.That(applyPostingJournalViewModel.ApplyPostingLines[i].SortOrder ?? 0, Is.LessThanOrEqualTo(applyPostingJournalViewModel.ApplyPostingLines[i - 1].SortOrder ?? 0));
            }
        }
Exemple #2
0
        public async Task AddPostingLineToPostingJournal_WhenPostingLineCannotBeDeserializedToApplyPostingLineViewModel_ReturnsBadRequestResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), _fixture.Create <string>());

            Assert.That(result, Is.TypeOf <BadRequestResult>());
        }
Exemple #3
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereViewNameIsEqualToPostingJournalPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            Assert.That(result.ViewName, Is.EqualTo("_PostingJournalPartial"));
        }
Exemple #4
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyIsWhiteSpace_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), " ", BuildPostingLineJson());

            Assert.That(result, Is.Not.Null);
        }
Exemple #5
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModel()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            Assert.That(result.Model, Is.TypeOf <ApplyPostingJournalViewModel>());
        }
Exemple #6
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValid_ReturnsPartialViewResultWhereViewDataContainingKeyForPostingJournalKey()
        {
            Controller sut = CreateSut(_random.Next(100) > 50);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            Assert.That(result.ViewData.ContainsKey("PostingJournalKey"), Is.True);
        }
Exemple #7
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            Assert.That(result, Is.Not.Null);
        }
Exemple #8
0
        public async Task AddPostingLineToPostingJournal_WhenPostingLineIsWhiteSpace_ReturnsBadRequestResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), " ");

            Assert.That(result, Is.TypeOf <BadRequestResult>());
        }
Exemple #9
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndPostingJournalHeaderIsNotNullEmptyOrWhiteSpace_ReturnsPartialViewResultWhereWithViewContainingHeaderWithValueNotEqualToNull()
        {
            Controller sut = CreateSut(_random.Next(100) > 50);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson(), _fixture.Create <string>());

            Assert.That(result.ViewData["Header"], Is.Not.Null);
        }
Exemple #10
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndPostingJournalHeaderIsWhiteSpace_ReturnsPartialViewResultWhereWithViewDataDoesNotContainKeyForHeader()
        {
            Controller sut = CreateSut(_random.Next(100) > 50);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson(), " ");

            Assert.That(result.ViewData.ContainsKey("Header"), Is.False);
        }
Exemple #11
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyIsEmpty_ReturnsBadRequestResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), string.Empty, BuildPostingLineJson());

            Assert.That(result, Is.TypeOf <BadRequestResult>());
        }
Exemple #12
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValid_ReturnsPartialViewResultWhereViewDataIsNotEqualToNull()
        {
            Controller sut = CreateSut(_random.Next(100) > 50);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            Assert.That(result.ViewData, Is.Not.Null);
        }
Exemple #13
0
        public async Task AddPostingLineToPostingJournal_WhenPostingLineIsEmpty_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), string.Empty);

            Assert.That(result, Is.Not.Null);
        }
Exemple #14
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_AssertToObjectWasCalledOnKeyValueEntryForPostingJournal()
        {
            Mock <IKeyValueEntry> keyValueEntryForPostingJournalMock = BuildKeyValueEntryForPostingJournalMock();
            Controller            sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournalMock.Object);

            await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            keyValueEntryForPostingJournalMock.Verify(m => m.ToObject <It.IsSubtype <ApplyPostingJournalViewModel> >(), Times.Once);
        }
Exemple #15
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValid_AssertQueryAsyncWasCalledOnQueryBusWithPullKeyValueEntryQueryForPostingJournalKey()
        {
            Controller sut = CreateSut();

            string postingJournalKey = _fixture.Create <string>();
            await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), postingJournalKey, BuildPostingLineJson());

            _queryBusMock.Verify(m => m.QueryAsync <IPullKeyValueEntryQuery, IKeyValueEntry>(It.Is <IPullKeyValueEntryQuery>(query => query != null && string.CompareOrdinal(query.Key, postingJournalKey) == 0)), Times.Once);
        }
Exemple #16
0
        public async Task AddPostingLineToPostingJournal_WhenPostingLineIsInvalid_ReturnsBadRequestObjectResultWhereValueIsString()
        {
            Controller sut = CreateSut();

            string postingLine            = BuildPostingLineJson(hasDetails: false);
            BadRequestObjectResult result = (BadRequestObjectResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), postingLine);

            Assert.That(result.Value, Is.TypeOf <string>());
        }
Exemple #17
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValid_ReturnsPartialViewResultWhereViewDataContainingPostingJournalKeyWithValueEqualToPostingJournalKeyFromArguments()
        {
            Controller sut = CreateSut(_random.Next(100) > 50);

            string            postingJournalKey = _fixture.Create <string>();
            PartialViewResult result            = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), postingJournalKey, BuildPostingLineJson());

            Assert.That(result.ViewData["PostingJournalKey"], Is.EqualTo(postingJournalKey));
        }
Exemple #18
0
        public async Task AddPostingLineToPostingJournal_WhenPostingLineIsInvalid_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            string        postingLine = BuildPostingLineJson(hasDetails: false);
            IActionResult result      = await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), postingLine);

            Assert.That(result, Is.Not.Null);
        }
Exemple #19
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithApplyPostingLinesNotEqualToNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.ApplyPostingLines, Is.Not.Null);
        }
Exemple #20
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithApplyPostingLinesContainingOneItem()
        {
            Controller sut = CreateSut(false);

            int accountingNumber     = _fixture.Create <int>();
            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(accountingNumber, _fixture.Create <string>(), BuildPostingLineJson());

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.ApplyPostingLines.Count, Is.EqualTo(1));
        }
Exemple #21
0
        public async Task AddPostingLineToPostingJournal_WhenPostingLineIsInvalid_ReturnsBadRequestObjectResultWhereValueIsStringStartingWithSubmittedMessageIsInvalid()
        {
            Controller sut = CreateSut();

            string postingLine            = BuildPostingLineJson(hasDetails: false);
            BadRequestObjectResult result = (BadRequestObjectResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), postingLine);

            string errorMessage = (string)result.Value;

            Assert.That(errorMessage.StartsWith("The submitted message is invalid:"), Is.True);
        }
Exemple #22
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_AssertPublishAsyncWasCalledOnCommandBusWithPushKeyValueEntryCommandForPostingJournal()
        {
            Controller sut = CreateSut(false);

            int    accountingNumber      = _fixture.Create <int>();
            string postingJournalKey     = _fixture.Create <string>();
            Guid   postingLineIdentifier = Guid.NewGuid();
            string postingLine           = BuildPostingLineJson(postingLineIdentifier);
            await sut.AddPostingLineToPostingJournal(accountingNumber, postingJournalKey, postingLine);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IPushKeyValueEntryCommand>(command => command != null && string.CompareOrdinal(command.Key, postingJournalKey) == 0 && command.Value != null && command.Value.GetType() == typeof(ApplyPostingJournalViewModel) && ((ApplyPostingJournalViewModel)command.Value).AccountingNumber == accountingNumber && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines != null && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines.Count == 1 && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines.Any(applyPostingLine => applyPostingLine.Identifier == postingLineIdentifier))), Times.Once);
        }
Exemple #23
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithApplyPostingLinesContainingPostingLineFromArguments()
        {
            Controller sut = CreateSut(false);

            Guid              postingLineIdentifier = Guid.NewGuid();
            string            postingLineJson       = BuildPostingLineJson(postingLineIdentifier);
            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), postingLineJson);

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.ApplyPostingLines.SingleOrDefault(applyPostingLine => applyPostingLine.Identifier == postingLineIdentifier), Is.Not.Null);
        }
Exemple #24
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithAccountingNumberEqualToAccountingNumberFromReturnedPostingJournal()
        {
            int accountingNumber = _fixture.Create <int>();
            ApplyPostingJournalViewModel savedApplyPostingJournalViewModel = BuildApplyPostingJournalViewModel(accountingNumber);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(savedApplyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.AccountingNumber, Is.EqualTo(accountingNumber));
        }
Exemple #25
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithApplyPostingLinesContainingExistingItemsPlusOne()
        {
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>());
            ApplyPostingJournalViewModel savedApplyPostingJournalViewModel = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(savedApplyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            PartialViewResult result = (PartialViewResult)await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), BuildPostingLineJson());

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.ApplyPostingLines.Count, Is.EqualTo(3));
        }