public async Task QueryAsync_WhenQueryIsNotNullAndKeyValueEntryWasReturnedFromCommonRepository_ReturnNotNull()
        {
            QueryHandler sut = CreateSut();

            IKeyValueEntry result = await sut.QueryAsync(BuildPullKeyValueEntryQuery());

            Assert.That(result, Is.Not.Null);
        }
Esempio n. 2
0
        public void ToObject_WhenCalled_ReturnsNotNull()
        {
            IKeyValueEntry sut = CreateSut();

            TestValue result = sut.ToObject <TestValue>();

            Assert.That(result, Is.Not.Null);
        }
        public void ToBase64_WhenCalled_ReturnsBase64StringMatchingValue()
        {
            byte[]         value = _fixture.CreateMany <byte>(_random.Next(1024, 4096)).ToArray();
            IKeyValueEntry sut   = CreateSut(value);

            string base64String = sut.ToBase64();

            Assert.That(base64String, Is.EqualTo(Convert.ToBase64String(value)));
        }
        public async Task QueryAsync_WhenQueryIsNotNullAndKeyValueEntryWasReturnedFromCommonRepository_ReturnKeyValueEntryFromCommonRepository()
        {
            IKeyValueEntry keyValueEntry = _fixture.BuildKeyValueEntryMock <object>().Object;
            QueryHandler   sut           = CreateSut(keyValueEntry: keyValueEntry);

            IKeyValueEntry result = await sut.QueryAsync(BuildPullKeyValueEntryQuery());

            Assert.That(result, Is.EqualTo(keyValueEntry));
        }
Esempio n. 5
0
        private Controller CreateSut(bool hasKeyValueEntryForPostingJournal = true, IKeyValueEntry keyValueEntryForPostingJournal = null)
        {
            _queryBusMock.Setup(m => m.QueryAsync <IPullKeyValueEntryQuery, IKeyValueEntry>(It.IsAny <IPullKeyValueEntryQuery>()))
            .Returns(Task.FromResult(hasKeyValueEntryForPostingJournal ? keyValueEntryForPostingJournal ?? BuildKeyValueEntryForPostingJournal() : null));
            _commandBusMock.Setup(m => m.PublishAsync(It.IsAny <IPushKeyValueEntryCommand>()))
            .Returns(Task.CompletedTask);

            return(new Controller(_commandBusMock.Object, _queryBusMock.Object, _claimResolverMock.Object));
        }
Esempio n. 6
0
        public void ToDomain_WhenCalled_ReturnsKeyValueEntryWhereValueIsEqualToByteArrayOfValueOnPushKeyValueEntryCommand()
        {
            TestValue value = BuildTestValue();
            IPushKeyValueEntryCommand sut = CreateSut(value: value);

            IKeyValueEntry result = sut.ToDomain();

            Assert.That(Convert.ToBase64String(result.Value), Is.EqualTo(value.ToBase64()));
        }
        public async Task PullKeyValueEntryAsync_WhenKeyHasNotBeenPushed_ReturnsNull()
        {
            ICommonRepository sut = CreateSut();

            string         key    = BuildKey();
            IKeyValueEntry result = await sut.PullKeyValueEntryAsync(key);

            Assert.That(result, Is.Null);
        }
Esempio n. 8
0
        public void ToDomain_WhenCalled_ReturnsKeyValueEntryWhereKeyIsEqualToKeyOnPushKeyValueEntryCommand()
        {
            string key = _fixture.Create <string>();
            IPushKeyValueEntryCommand sut = CreateSut(key);

            IKeyValueEntry result = sut.ToDomain();

            Assert.That(result.Key, Is.EqualTo(key));
        }
        public async Task ExecuteAsync_WhenCommandIsNotNull_AssertPushKeyValueEntryAsyncWasCalledOnCommonRepository()
        {
            CommandHandler sut = CreateSut();

            IKeyValueEntry            keyValueEntry            = _fixture.BuildKeyValueEntryMock <object>().Object;
            IPushKeyValueEntryCommand pushKeyValueEntryCommand = BuildPushKeyValueEntryCommand(keyValueEntry);
            await sut.ExecuteAsync(pushKeyValueEntryCommand);

            _commonRepositoryMock.Verify(m => m.PushKeyValueEntryAsync(It.Is <IKeyValueEntry>(value => value != null && value == keyValueEntry)), Times.Once);
        }
        public Task <IKeyValueEntry> PushKeyValueEntryAsync(IKeyValueEntry keyValueEntry)
        {
            NullGuard.NotNull(keyValueEntry, nameof(keyValueEntry));

            return(ExecuteAsync(async() =>
            {
                using KeyValueEntryModelHandler keyValueEntryModelHandler = new KeyValueEntryModelHandler(DbContext, CommonModelConverter.Create());
                return await keyValueEntryModelHandler.PushAsync(keyValueEntry);
            },
                                MethodBase.GetCurrentMethod()));
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryDoesNotContainPostingWarningForPostingWarningIdentifier_AssertPublishAsyncWasNotCalledOnCommandBusWithDeleteKeyValueEntryCommandForPostingJournalResult()
        {
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(BuildPostingWarningIdentifierCollection());
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid());

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IDeleteKeyValueEntryCommand>()), Times.Never());
        }
        internal static IKeyValueEntry ToDomain(this KeyValueEntryModel keyValueEntryModel)
        {
            NullGuard.NotNull(keyValueEntryModel, nameof(keyValueEntryModel));

            IKeyValueEntry keyValueEntry = KeyValueEntry.Create(keyValueEntryModel.Key, keyValueEntryModel.Value);

            keyValueEntry.AddAuditInformation(keyValueEntryModel.CreatedUtcDateTime, keyValueEntryModel.CreatedByIdentifier, keyValueEntryModel.ModifiedUtcDateTime, keyValueEntryModel.ModifiedByIdentifier);
            keyValueEntry.SetDeletable(keyValueEntryModel.Deletable);

            return(keyValueEntry);
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndKeyValueEntryForPostingJournalResultWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultEqualToPostingJournalResultFromQueryBus()
        {
            ApplyPostingJournalResultViewModel postingJournalResult = _fixture.Create <ApplyPostingJournalResultViewModel>();
            IKeyValueEntry keyValueEntryForPostingJournalResultKey  = _fixture.BuildKeyValueEntryMock(toObject: postingJournalResult).Object;
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResultKey: keyValueEntryForPostingJournalResultKey);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournalResult, Is.EqualTo(postingJournalResult));
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryDoesNotContainPostingWarningForPostingWarningIdentifier_AssertQueryAsyncWasCalledOnceOnQueryBusWithPullKeyValueEntryQueryForPostingJournalResultKey()
        {
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(BuildPostingWarningIdentifierCollection());
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            string postingJournalResultKey = _fixture.Create <string>();
            await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), postingJournalResultKey, Guid.NewGuid());

            _queryBusMock.Verify(m => m.QueryAsync <IPullKeyValueEntryQuery, IKeyValueEntry>(It.Is <IPullKeyValueEntryQuery>(query => query != null && string.CompareOrdinal(query.Key, postingJournalResultKey) == 0)), Times.Once);
        }
        public async Task RemovePostingLineFromPostingJournal_WhenPostingJournalKeyHasValueAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithAccountingNumberEqualToAccountingNumberFromReturnedPostingJournal()
        {
            int accountingNumber = _fixture.Create <int>();
            ApplyPostingJournalViewModel savedApplyPostingJournalViewModel = BuildApplyPostingJournalViewModel(accountingNumber);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(savedApplyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            PartialViewResult result = (PartialViewResult)await sut.RemovePostingLineFromPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid());

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.AccountingNumber, Is.EqualTo(accountingNumber));
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryDoesNotContainPostingWarningForPostingWarningIdentifier_AssertPublishAsyncWasCalledOnCommandBusWithPushKeyValueEntryCommandForPostingJournalResult()
        {
            Guid[] postingWarningIdentifierCollection = BuildPostingWarningIdentifierCollection();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifierCollection);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            string postingJournalResultKey = _fixture.Create <string>();
            await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), postingJournalResultKey, Guid.NewGuid());

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IPushKeyValueEntryCommand>(command => command != null && string.CompareOrdinal(command.Key, postingJournalResultKey) == 0 && command.Value != null && command.Value.GetType() == typeof(ApplyPostingJournalResultViewModel) && ((ApplyPostingJournalResultViewModel)command.Value).PostingLines != null && ((ApplyPostingJournalResultViewModel)command.Value).PostingLines.Count == 0 && ((ApplyPostingJournalResultViewModel)command.Value).PostingWarnings != null && ((ApplyPostingJournalResultViewModel)command.Value).PostingWarnings.Count == postingWarningIdentifierCollection.Length && ((ApplyPostingJournalResultViewModel)command.Value).PostingWarnings.All(postingWarningViewModel => postingWarningIdentifierCollection.Any(postingWarningIdentifier => postingWarningViewModel.Identifier == postingWarningIdentifier)))), Times.Once);
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryContainsMultiplePostingWarningsWhereOneMatchesPostingWarningIdentifier_AssertPublishAsyncWasNotCalledOnCommandBusWithDeleteKeyValueEntryCommandForPostingJournalResult()
        {
            Guid[] postingWarningIdentifierCollection = BuildPostingWarningIdentifierCollection();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifierCollection);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            Guid postingWarningIdentifier = postingWarningIdentifierCollection[_random.Next(0, postingWarningIdentifierCollection.Length - 1)];
            await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), postingWarningIdentifier);

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IDeleteKeyValueEntryCommand>()), Times.Never());
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryContainsOnePostingWarningMatchingPostingWarningIdentifier_AssertPublishAsyncWasCalledOnCommandBusWithDeleteKeyValueEntryCommandForPostingJournalResult()
        {
            Guid postingWarningIdentifier = Guid.NewGuid();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifier);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            string postingJournalResultKey = _fixture.Create <string>();
            await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), postingJournalResultKey, postingWarningIdentifier);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IDeleteKeyValueEntryCommand>(command => command != null && string.CompareOrdinal(command.Key, postingJournalResultKey) == 0)), Times.Once);
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryContainsMultiplePostingWarningsWhereOneMatchesPostingWarningIdentifier_AssertQueryAsyncWasCalledOnceOnQueryBusWithPullKeyValueEntryQueryForPostingJournalResultKey()
        {
            Guid[] postingWarningIdentifierCollection = BuildPostingWarningIdentifierCollection();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifierCollection);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            string postingJournalResultKey  = _fixture.Create <string>();
            Guid   postingWarningIdentifier = postingWarningIdentifierCollection[_random.Next(0, postingWarningIdentifierCollection.Length - 1)];
            await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), postingJournalResultKey, postingWarningIdentifier);

            _queryBusMock.Verify(m => m.QueryAsync <IPullKeyValueEntryQuery, IKeyValueEntry>(It.Is <IPullKeyValueEntryQuery>(query => query != null && string.CompareOrdinal(query.Key, postingJournalResultKey) == 0)), Times.Once);
        }
        public async Task RemovePostingLineFromPostingJournal_WhenPostingJournalKeyHasValueAndPostingJournalFromKeyValueContainsOnePostingLinesMatchingPostingLineIdentifier_AssertQueryAsyncWasCalledTwiceOnQueryBusWithPullKeyValueEntryQueryForPostingJournalKey()
        {
            Guid postingLineIdentifier = Guid.NewGuid();
            ApplyPostingLineViewModel           applyPostingLineViewModel           = BuildApplyPostingLineViewModel(postingLineIdentifier);
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(applyPostingLineViewModel);
            ApplyPostingJournalViewModel        applyPostingJournalViewModel        = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(applyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            string postingJournalKey = _fixture.Create <string>();
            await sut.RemovePostingLineFromPostingJournal(_fixture.Create <int>(), postingJournalKey, postingLineIdentifier);

            _queryBusMock.Verify(m => m.QueryAsync <IPullKeyValueEntryQuery, IKeyValueEntry>(It.Is <IPullKeyValueEntryQuery>(query => query != null && string.CompareOrdinal(query.Key, postingJournalKey) == 0)), Times.Exactly(2));
        }
        public async Task RemovePostingLineFromPostingJournal_WhenPostingJournalKeyHasValueAndPostingJournalFromKeyValueContainsOnePostingLinesMatchingPostingLineIdentifier_AssertPublishAsyncWasNotCalledOnCommandBusWithPushKeyValueEntryCommandForPostingJournal()
        {
            Guid postingLineIdentifier = Guid.NewGuid();
            ApplyPostingLineViewModel           applyPostingLineViewModel           = BuildApplyPostingLineViewModel(postingLineIdentifier);
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(applyPostingLineViewModel);
            ApplyPostingJournalViewModel        applyPostingJournalViewModel        = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(applyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            string postingJournalKey = _fixture.Create <string>();
            await sut.RemovePostingLineFromPostingJournal(_fixture.Create <int>(), postingJournalKey, postingLineIdentifier);

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IPushKeyValueEntryCommand>()), Times.Never());
        }
        public async Task RemovePostingLineFromPostingJournal_WhenPostingJournalKeyHasValueAndPostingJournalFromKeyValueEntryDoesNotContainPostingLineForPostingLineIdentifier_AssertPublishAsyncWasNotCalledOnCommandBusWithDeleteKeyValueEntryCommandForPostingJournal()
        {
            ApplyPostingLineViewModel           applyPostingLineViewModel1          = BuildApplyPostingLineViewModel();
            ApplyPostingLineViewModel           applyPostingLineViewModel2          = BuildApplyPostingLineViewModel();
            ApplyPostingLineViewModel           applyPostingLineViewModel3          = BuildApplyPostingLineViewModel();
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(applyPostingLineViewModel1, applyPostingLineViewModel2, applyPostingLineViewModel3);
            ApplyPostingJournalViewModel        applyPostingJournalViewModel        = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(applyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            await sut.RemovePostingLineFromPostingJournal(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid());

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IDeleteKeyValueEntryCommand>()), Times.Never());
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryDoesNotContainPostingWarningForPostingWarningIdentifier_ReturnsPartialViewResultWhereModelIsPostingWarningCollectionViewModelWithPostingWarningsFromReturnedPostingJournalResult()
        {
            Guid[] postingWarningIdentifierCollection = BuildPostingWarningIdentifierCollection();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifierCollection);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid());

            PostingWarningCollectionViewModel resultViewModel = (PostingWarningCollectionViewModel)result.Model;

            Assert.That(resultViewModel.All(postingWarningViewModel => postingWarningIdentifierCollection.Any(postingWarningIdentifier => postingWarningViewModel.Identifier == postingWarningIdentifier)), Is.True);
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryContainsOnePostingWarningMatchingPostingWarningIdentifier_ReturnsPartialViewResultWhereModelIsPostingWarningCollectionViewModelWithEmptyPostingWarnings()
        {
            Guid postingWarningIdentifier = Guid.NewGuid();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifier);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

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

            PostingWarningCollectionViewModel resultViewModel = (PostingWarningCollectionViewModel)result.Model;

            Assert.That(resultViewModel, Is.Empty);
        }
        public async Task RemovePostingLineFromPostingJournal_WhenPostingJournalKeyHasValueAndPostingJournalFromKeyValueContainsOnePostingLinesMatchingPostingLineIdentifier_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithEmptyApplyPostingLines()
        {
            Guid postingLineIdentifier = Guid.NewGuid();
            ApplyPostingLineViewModel           postingLine           = BuildApplyPostingLineViewModel(postingLineIdentifier);
            ApplyPostingLineCollectionViewModel postingLineCollection = BuildApplyPostingLineCollectionViewModel(postingLine);
            ApplyPostingJournalViewModel        postingJournal        = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: postingLineCollection);
            IKeyValueEntry keyValueEntryForPostingJournal             = BuildKeyValueEntryForPostingJournal(postingJournal);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

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

            ApplyPostingJournalViewModel applyPostingJournalViewModel = (ApplyPostingJournalViewModel)result.Model;

            Assert.That(applyPostingJournalViewModel.ApplyPostingLines, Is.Empty);
        }
Esempio n. 26
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));
        }
        public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryContainsMultiplePostingWarningsWhereOneMatchesPostingWarningIdentifier_ReturnsPartialViewResultWhereModelIsPostingWarningCollectionViewModelWithPostingWarningsFromReturnedPostingJournalResultExceptPostingWarningForPostingWarningIdentifier()
        {
            Guid[] postingWarningIdentifierCollection = BuildPostingWarningIdentifierCollection();
            PostingWarningCollectionViewModel  postingWarningCollectionViewModel  = BuildPostingWarningCollectionViewModel(postingWarningIdentifierCollection);
            ApplyPostingJournalResultViewModel applyPostingJournalResultViewModel = BuildApplyPostingJournalResultViewModel(postingWarningCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournalResult = BuildKeyValueEntryForPostingJournalResult(applyPostingJournalResultViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResult);

            Guid postingWarningIdentifier = postingWarningIdentifierCollection[_random.Next(0, postingWarningIdentifierCollection.Length - 1)];
            PartialViewResult result      = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), postingWarningIdentifier);

            PostingWarningCollectionViewModel resultViewModel = (PostingWarningCollectionViewModel)result.Model;

            Assert.That(resultViewModel.All(postingWarningViewModel => postingWarningIdentifierCollection.Where(identifier => identifier != postingWarningIdentifier).Any(identifier => postingWarningViewModel.Identifier == identifier)), Is.True);
        }
Esempio n. 28
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_AssertPublishAsyncWasCalledOnCommandBusWithPushKeyValueEntryCommandForPostingJournal()
        {
            int accountingNumber = _fixture.Create <int>();
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(_fixture.Create <ApplyPostingLineViewModel>(), _fixture.Create <ApplyPostingLineViewModel>());
            ApplyPostingJournalViewModel        applyPostingJournalViewModel        = BuildApplyPostingJournalViewModel(accountingNumber, applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(applyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            string postingJournalKey     = _fixture.Create <string>();
            Guid   postingLineIdentifier = Guid.NewGuid();
            string postingLine           = BuildPostingLineJson(postingLineIdentifier);
            await sut.AddPostingLineToPostingJournal(_fixture.Create <int>(), 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 == 3 && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines.Any(applyPostingLine => applyPostingLine.Identifier == postingLineIdentifier))), Times.Once);
        }
        public async Task RemovePostingLineFromPostingJournal_WhenPostingJournalKeyHasValueAndPostingJournalFromKeyValueEntryDoesNotContainPostingLineForPostingLineIdentifier_AssertPublishAsyncWasCalledOnCommandBusWithPushKeyValueEntryCommandForPostingJournal()
        {
            int accountingNumber = _fixture.Create <int>();
            ApplyPostingLineViewModel           applyPostingLineViewModel1          = BuildApplyPostingLineViewModel();
            ApplyPostingLineViewModel           applyPostingLineViewModel2          = BuildApplyPostingLineViewModel();
            ApplyPostingLineViewModel           applyPostingLineViewModel3          = BuildApplyPostingLineViewModel();
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(applyPostingLineViewModel1, applyPostingLineViewModel2, applyPostingLineViewModel3);
            ApplyPostingJournalViewModel        applyPostingJournalViewModel        = BuildApplyPostingJournalViewModel(accountingNumber, applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(applyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            string postingJournalKey = _fixture.Create <string>();
            await sut.RemovePostingLineFromPostingJournal(_fixture.Create <int>(), postingJournalKey, Guid.NewGuid());

            _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 == 3 && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines.Contains(applyPostingLineViewModel1) && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines.Contains(applyPostingLineViewModel2) && ((ApplyPostingJournalViewModel)command.Value).ApplyPostingLines.Contains(applyPostingLineViewModel3))), Times.Once);
        }
Esempio n. 30
0
        public async Task AddPostingLineToPostingJournal_WhenPostingJournalKeyHasValueAndPostingLineIsValidAndKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsApplyPostingJournalViewModelWithApplyPostingLinesContainingPostingLineFromArguments()
        {
            ApplyPostingLineCollectionViewModel applyPostingLineCollectionViewModel = BuildApplyPostingLineCollectionViewModel(
                _fixture.Create <ApplyPostingLineViewModel>(),
                _fixture.Create <ApplyPostingLineViewModel>());
            ApplyPostingJournalViewModel savedApplyPostingJournalViewModel = BuildApplyPostingJournalViewModel(applyPostingLineCollectionViewModel: applyPostingLineCollectionViewModel);
            IKeyValueEntry keyValueEntryForPostingJournal = BuildKeyValueEntryForPostingJournal(savedApplyPostingJournalViewModel);
            Controller     sut = CreateSut(keyValueEntryForPostingJournal: keyValueEntryForPostingJournal);

            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);
        }