public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModel() { Controller sut = CreateSut(); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); Assert.That(result.Model, Is.TypeOf <AccountingViewModel>()); }
public async Task LoadAccounting_WhenCalled_AssertQueryAsyncWasCalledOnQueryBusWithEmptyQueryForLetterHeadCollection() { Controller sut = CreateSut(); await sut.LoadAccounting(_fixture.Create <int>()); _queryBusMock.Verify(m => m.QueryAsync <EmptyQuery, IEnumerable <ILetterHead> >(It.IsNotNull <EmptyQuery>()), Times.Once); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereViewNameIsEqualToPresentAccountingPartial() { Controller sut = CreateSut(); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); Assert.That(result.ViewName, Is.EqualTo("_PresentAccountingPartial")); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResult() { Controller sut = CreateSut(); IActionResult result = await sut.LoadAccounting(_fixture.Create <int>()); Assert.That(result, Is.TypeOf <PartialViewResult>()); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsNotNull() { Controller sut = CreateSut(); IActionResult result = await sut.LoadAccounting(_fixture.Create <int>()); Assert.That(result, Is.Not.Null); }
public async Task LoadAccounting_WhenNoAccountingWasReturnedFromQueryBus_ReturnsBadRequestResult() { Controller sut = CreateSut(hasAccounting: false); IActionResult result = await sut.LoadAccounting(_fixture.Create <int>()); Assert.That(result, Is.TypeOf <BadRequestResult>()); }
public async Task LoadAccounting_WhenCalled_AssertQueryAsyncWasCalledOnQueryBusWithPullKeyValueEntryQueryForPostingJournalKey() { string postingJournalKey = _fixture.Create <string>(); Controller sut = CreateSut(postingJournalKey: postingJournalKey); await sut.LoadAccounting(_fixture.Create <int>()); _queryBusMock.Verify(m => m.QueryAsync <IPullKeyValueEntryQuery, IKeyValueEntry>(It.Is <IPullKeyValueEntryQuery>(query => query != null && string.CompareOrdinal(query.Key, postingJournalKey) == 0)), Times.Once); }
public async Task LoadAccounting_WhenKeyValueEntryForPostingJournalResultKeyWasReturnedFromQueryBus_AssertToObjectWasCalledOnKeyValueEntryForPostingJournalResultKey() { Mock <IKeyValueEntry> keyValueEntryMockForPostingJournalResultKey = _fixture.BuildKeyValueEntryMock <ApplyPostingJournalResultViewModel>(); Controller sut = CreateSut(keyValueEntryForPostingJournalResultKey: keyValueEntryMockForPostingJournalResultKey.Object); await sut.LoadAccounting(_fixture.Create <int>()); keyValueEntryMockForPostingJournalResultKey.Verify(m => m.ToObject <It.IsSubtype <ApplyPostingJournalResultViewModel> >(), Times.Once); }
public async Task LoadAccounting_WhenCalled_AssertQueryAsyncWasCalledOnQueryBusWithGetAccountingQuery() { Controller sut = CreateSut(); int accountingNumber = _fixture.Create <int>(); await sut.LoadAccounting(accountingNumber); _queryBusMock.Verify(m => m.QueryAsync <IGetAccountingQuery, IAccounting>(It.Is <IGetAccountingQuery>(value => value != null && value.AccountingNumber == accountingNumber && value.StatusDate == DateTime.Today)), Times.Once); }
public async Task LoadAccounting_WhenCalled_AssertQueryAsyncWasCalledOnQueryBusWithGetUserSpecificKeyQueryForPostingJournalResultKey() { Controller sut = CreateSut(); int accountingNumber = _fixture.Create <int>(); await sut.LoadAccounting(accountingNumber); _queryBusMock.Verify(m => m.QueryAsync <IGetUserSpecificKeyQuery, string>(It.Is <IGetUserSpecificKeyQuery>(query => query != null && query.KeyElementCollection != null && query.KeyElementCollection.Count() == 2 && string.CompareOrdinal(query.KeyElementCollection.ElementAtOrDefault(0), nameof(ApplyPostingJournalResultViewModel)) == 0 && string.CompareOrdinal(query.KeyElementCollection.ElementAt(1), Convert.ToString(accountingNumber)) == 0)), Times.Once); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalWhereApplyPostingLinesNotEqualToNull() { Controller sut = CreateSut(hasKeyValueEntryForPostingJournalKey: false); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.PostingJournal.ApplyPostingLines, Is.Not.Null); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndNoKeyValueEntryForPostingJournalResultWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultWherePostingWarningsIsEmpty() { Controller sut = CreateSut(hasKeyValueEntryForPostingJournalResultKey: false); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.PostingJournalResult.PostingWarnings, Is.Empty); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultNotEqualToNull() { Controller sut = CreateSut(); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.PostingJournalResult, Is.Not.Null); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereEditModeIsEqualToNone() { Controller sut = CreateSut(); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.EditMode, Is.EqualTo(EditMode.None)); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultKeyEqualToPostingJournalResultKeyFromQueryBus() { string postingJournalResultKey = _fixture.Create <string>(); Controller sut = CreateSut(postingJournalResultKey: postingJournalResultKey); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.PostingJournalResultKey, Is.EqualTo(postingJournalResultKey)); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalWhereAccountingNumberIsEqualToAccountingNumberFromArgument() { Controller sut = CreateSut(hasKeyValueEntryForPostingJournalKey: false); int accountingNumber = _fixture.Create <int>(); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(accountingNumber); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.PostingJournal.AccountingNumber, Is.EqualTo(accountingNumber)); }
public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithAccountingNumberEqualToAccountingNumberOnAccountingFromQueryBus() { int accountingNumber = _fixture.Create <int>(); IAccounting accounting = _fixture.BuildAccountingMock(accountingNumber).Object; Controller sut = CreateSut(accounting: accounting); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.AccountingNumber, Is.EqualTo(accountingNumber)); }
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 LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereLetterHeadsIsEqualToLetterHeadCollectionFromQueryBus() { IEnumerable <ILetterHead> letterHeadCollection = _fixture.CreateMany <ILetterHead>(_random.Next(5, 10)).ToList(); Controller sut = CreateSut(letterHeadCollection); PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>()); AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model; Assert.That(accountingViewModel.LetterHeads, Is.Not.Null); Assert.That(accountingViewModel.LetterHeads.Count, Is.EqualTo(letterHeadCollection.Count())); Assert.That(accountingViewModel.LetterHeads.All(letterHeadViewModel => letterHeadCollection.Any(letterHead => letterHead.Number == letterHeadViewModel.Number)), Is.True); }