public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndPostingJournalResultFromKeyValueEntryContainsOnePostingWarningMatchingPostingWarningIdentifier_ReturnsPartialViewResultWhereModelIsPostingWarningCollectionViewModelWithSortedPostingWarnings() { 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; for (int i = 1; i < resultViewModel.Count; i++) { Assert.That(resultViewModel[i].PostingLine.PostingDate.Date, Is.LessThanOrEqualTo(resultViewModel[i - 1].PostingLine.PostingDate.Date)); if (resultViewModel[i].PostingLine.PostingDate.Date != resultViewModel[i - 1].PostingLine.PostingDate.Date) { continue; } Assert.That(resultViewModel[i].PostingLine.SortOrder, Is.LessThanOrEqualTo(resultViewModel[i - 1].PostingLine.SortOrder)); if (resultViewModel[i].PostingLine.SortOrder != resultViewModel[i - 1].PostingLine.SortOrder) { continue; } Assert.That((int)resultViewModel[i].Reason, Is.LessThanOrEqualTo((int)resultViewModel[i - 1].Reason)); } }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_ReturnsPartialViewResultWhereModelIsPostingWarningCollectionViewModel() { Controller sut = CreateSut(_random.Next(100) > 50); PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid()); Assert.That(result.Model, Is.TypeOf <PostingWarningCollectionViewModel>()); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyIsWhiteSpace_ReturnsNotNull() { Controller sut = CreateSut(); IActionResult result = await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), " ", Guid.NewGuid()); Assert.That(result, Is.Not.Null); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_ReturnsNotNull() { Controller sut = CreateSut(_random.Next(100) > 50); IActionResult result = await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid()); Assert.That(result, Is.Not.Null); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_ReturnsPartialViewResultWhereViewNameIsEqualToPostingWarningCollectionPartial() { Controller sut = CreateSut(_random.Next(100) > 50); PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid()); Assert.That(result.ViewName, Is.EqualTo("_PostingWarningCollectionPartial")); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_ReturnsPartialViewResultWhereViewDataContainsKeyForPostingJournalResultKey() { Controller sut = CreateSut(_random.Next(100) > 50); PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid()); Assert.That(result.ViewData.ContainsKey("PostingJournalResultKey"), Is.True); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyIsEmpty_ReturnsBadRequestResult() { Controller sut = CreateSut(); IActionResult result = await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), string.Empty, Guid.NewGuid()); Assert.That(result, Is.TypeOf <BadRequestResult>()); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_ReturnsPartialViewResultWhereViewDataContainsKeyForAccountingNumberWhereValueIsEqualToAccountingNumberFromArguments() { Controller sut = CreateSut(_random.Next(100) > 50); int accountingNumber = _fixture.Create <int>(); PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(accountingNumber, _fixture.Create <string>(), Guid.NewGuid()); Assert.That(result.ViewData["AccountingNumber"], Is.EqualTo(accountingNumber)); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndKeyValueEntryForPostingJournalResultWasReturnedFromQueryBus_AssertToObjectWasCalledOnKeyValueEntryForPostingJournalResult() { Mock <IKeyValueEntry> keyValueEntryForPostingJournalResultMock = BuildKeyValueEntryForPostingJournalResultMock(); Controller sut = CreateSut(keyValueEntryForPostingJournalResult: keyValueEntryForPostingJournalResultMock.Object); await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid()); keyValueEntryForPostingJournalResultMock.Verify(m => m.ToObject <It.IsSubtype <ApplyPostingJournalResultViewModel> >(), Times.Once); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_ReturnsPartialViewResultWhereViewDataContainsKeyForPostingJournalResultKeyWhereValueIsEqualToPostingJournalResultKeyFromArguments() { Controller sut = CreateSut(_random.Next(100) > 50); string postingJournalResultKey = _fixture.Create <string>(); PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), postingJournalResultKey, Guid.NewGuid()); Assert.That(result.ViewData["PostingJournalResultKey"], Is.EqualTo(postingJournalResultKey)); }
public async Task RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValue_AssertQueryAsyncWasCalledOnQueryBusWithPullKeyValueEntryQueryForPostingJournalResultKey() { Controller sut = CreateSut(); 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 RemovePostingWarningFromPostingJournalResult_WhenPostingJournalResultKeyHasValueAndNoKeyValueEntryForPostingJournalResultWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsPostingWarningCollectionViewModelWithEmptyPostingWarnings() { Controller sut = CreateSut(false); PartialViewResult result = (PartialViewResult)await sut.RemovePostingWarningFromPostingJournalResult(_fixture.Create <int>(), _fixture.Create <string>(), Guid.NewGuid()); PostingWarningCollectionViewModel resultViewModel = (PostingWarningCollectionViewModel)result.Model; Assert.That(resultViewModel, Is.Empty); }
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()); }
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 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_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_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 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 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); }