예제 #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));
            }
        }
예제 #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>());
        }
예제 #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"));
        }
예제 #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);
        }
예제 #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>());
        }
예제 #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);
        }
예제 #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);
        }
예제 #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>());
        }
예제 #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);
        }
예제 #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);
        }
예제 #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>());
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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>());
        }
예제 #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));
        }
예제 #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);
        }
예제 #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);
        }
예제 #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));
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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));
        }
예제 #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));
        }