Exemplo n.º 1
0
        public async Task UpdateAccount_WhenAccountViewModelIsValidWithCreditInfosOnlyContainingDataForLastYear_AssertPublishAsyncWasCalledOnCommandBusWithUpdateAccountCommandContainingEmptyCreditInfoCollection()
        {
            Controller sut = CreateSut();

            CreditInfoDictionaryViewModel creditInfoDictionaryViewModel = CreateCreditInfoDictionaryViewModel(CreateCreditInfoViewModelCollectionForLastYear());
            AccountViewModel accountViewModel = CreateAccountViewModel(creditInfoDictionaryViewModel: creditInfoDictionaryViewModel);

            await sut.UpdateAccount(accountViewModel);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdateAccountCommand>(command => command != null && command.CreditInfoCollection.Any() == false)), Times.Once);
        }
Exemplo n.º 2
0
        public async Task UpdateAccount_WhenAccountViewModelIsValidWithCreditInfosOnlyContainingDataForYearToDate_AssertPublishAsyncWasCalledOnCommandBusWithUpdateAccountCommandContainingCreditInfoCollectionWithCreditInfoForCurrentMonth()
        {
            Controller sut = CreateSut();

            CreditInfoDictionaryViewModel creditInfoDictionaryViewModel = CreateCreditInfoDictionaryViewModel(CreateCreditInfoViewModelCollectionForYearToDate());
            AccountViewModel accountViewModel = CreateAccountViewModel(creditInfoDictionaryViewModel: creditInfoDictionaryViewModel);

            await sut.UpdateAccount(accountViewModel);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdateAccountCommand>(command => command != null && command.CreditInfoCollection.All(creditInfo => creditInfo.Year == (short)DateTime.Today.Year && creditInfo.Month == (short)DateTime.Today.Month))), Times.Once);
        }
        public async Task CreateAccount_WhenAccountViewModelIsValidWithCreditInfosOnlyContainingDataForYearToDate_AssertPublishAsyncWasCalledOnCommandBusWithCreateAccountCommandContainingCreditInfoCollectionWithOneCreditInfo()
        {
            Controller sut = CreateSut();

            CreditInfoDictionaryViewModel creditInfoDictionaryViewModel = CreateCreditInfoDictionaryViewModel(CreateCreditInfoViewModelCollectionForYearToDate());
            AccountViewModel accountViewModel = CreateAccountViewModel(creditInfoDictionaryViewModel: creditInfoDictionaryViewModel);

            await sut.CreateAccount(accountViewModel);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <ICreateAccountCommand>(command => command != null && command.CreditInfoCollection.Count() == 1)), Times.Once);
        }
Exemplo n.º 4
0
        public async Task UpdateAccount_WhenAccountViewModelIsValidWithCreditInfosOnlyContainingDataForNext11Months_AssertPublishAsyncWasCalledOnCommandBusWithUpdateAccountCommandContainingCreditInfoCollectionWithCreditInfoForNext11Months()
        {
            Controller sut = CreateSut();

            CreditInfoViewModel[]         creditInfoViewModelCollection = CreateCreditInfoViewModelCollectionForNext11Months().ToArray();
            CreditInfoDictionaryViewModel creditInfoDictionaryViewModel = CreateCreditInfoDictionaryViewModel(creditInfoViewModelCollection);
            AccountViewModel accountViewModel = CreateAccountViewModel(creditInfoDictionaryViewModel: creditInfoDictionaryViewModel);

            await sut.UpdateAccount(accountViewModel);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdateAccountCommand>(command => command != null && command.CreditInfoCollection.All(creditInfo => creditInfoViewModelCollection.SingleOrDefault(creditInfoViewModel => creditInfoViewModel.Year == creditInfo.Year && creditInfoViewModel.Month == creditInfo.Month) != null))), Times.Once);
        }
Exemplo n.º 5
0
 private AccountViewModel CreateAccountViewModel(AccountingIdentificationViewModel accountingIdentificationViewModel = null, string accountNumber = null, string accountName = null, bool hasDescription = true, string description = null, bool hasNote = true, string note = null, AccountGroupViewModel accountGroupViewModel = null, CreditInfoDictionaryViewModel creditInfoDictionaryViewModel = null)
 {
     return(_fixture.Build <AccountViewModel>()
            .With(m => m.Accounting, accountingIdentificationViewModel ?? CreateAccountingIdentificationViewModel())
            .With(m => m.AccountNumber, accountNumber ?? _fixture.Create <string>())
            .With(m => m.AccountName, accountName ?? _fixture.Create <string>())
            .With(m => m.Description, hasDescription ? description ?? _fixture.Create <string>() : null)
            .With(m => m.Note, hasNote ? note ?? _fixture.Create <string>() : null)
            .With(m => m.AccountGroup, accountGroupViewModel ?? CreateAccountGroupViewModel())
            .With(m => m.CreditInfos, creditInfoDictionaryViewModel ?? CreateCreditInfoDictionaryViewModel())
            .Create());
 }