Exemplo n.º 1
0
        public void StartLoadingAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingIdentificationViewModelWithNameEqualToNull()
        {
            Controller sut = CreateSut();

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

            AccountingIdentificationViewModel accountingIdentificationViewModel = (AccountingIdentificationViewModel)result.Model;

            Assert.That(accountingIdentificationViewModel.Name, Is.Null);
        }
Exemplo n.º 2
0
        public void StartLoadingAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingIdentificationViewModelWithAccountingNumberEqualToArgument()
        {
            Controller sut = CreateSut();

            int accountingNumber     = _fixture.Create <int>();
            PartialViewResult result = (PartialViewResult)sut.StartLoadingAccounting(accountingNumber);

            AccountingIdentificationViewModel accountingIdentificationViewModel = (AccountingIdentificationViewModel)result.Model;

            Assert.That(accountingIdentificationViewModel.AccountingNumber, Is.EqualTo(accountingNumber));
        }
Exemplo n.º 3
0
        public async Task UpdateAccount_WhenAccountViewModelIsValid_AssertPublishAsyncWasCalledOnCommandBusWithUpdateAccountCommandContainingAccountingNumberFromAccountViewModel()
        {
            Controller sut = CreateSut();

            int accountingNumber = _fixture.Create <int>();
            AccountingIdentificationViewModel accountingIdentificationViewModel = CreateAccountingIdentificationViewModel(accountingNumber);
            AccountViewModel accountViewModel = CreateAccountViewModel(accountingIdentificationViewModel);

            await sut.UpdateAccount(accountViewModel);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdateAccountCommand>(command => command != null && command.AccountingNumber == accountingNumber)), Times.Once);
        }
Exemplo n.º 4
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());
 }
Exemplo n.º 5
0
        public async Task UpdateAccount_WhenAccountViewModelIsValid_ReturnsRedirectToActionResultWhereRouteValuesContainsAccountingNumberWithAccountingNumberFromAccountViewModel()
        {
            Controller sut = CreateSut();

            int accountingNumber = _fixture.Create <int>();
            AccountingIdentificationViewModel accountingIdentificationViewModel = CreateAccountingIdentificationViewModel(accountingNumber);
            AccountViewModel accountViewModel = CreateAccountViewModel(accountingIdentificationViewModel);

            RedirectToActionResult result = (RedirectToActionResult)await sut.UpdateAccount(accountViewModel);

            Assert.That(result.RouteValues["accountingNumber"], Is.EqualTo(accountingNumber));
        }
 private ContactAccountViewModel CreateContactAccountViewModel(AccountingIdentificationViewModel accountingIdentificationViewModel = null, string accountNumber = null, string accountName = null, bool hasDescription = true, string description = null, bool hasNote = true, string note = null, bool hasMailAddress = true, string mailAddress = null, bool hasPrimaryPhone = true, string primaryPhone = null, bool hasSecondaryPhone = true, string secondaryPhone = null, PaymentTermViewModel paymentTermViewModel = null)
 {
     return(_fixture.Build <ContactAccountViewModel>()
            .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.MailAddress, hasMailAddress ? mailAddress ?? _fixture.Create <string>() : null)
            .With(m => m.PrimaryPhone, hasPrimaryPhone ? primaryPhone ?? _fixture.Create <string>() : null)
            .With(m => m.SecondaryPhone, hasSecondaryPhone ? secondaryPhone ?? _fixture.Create <string>() : null)
            .With(m => m.PaymentTerm, paymentTermViewModel ?? CreatePaymentTermViewModel())
            .With(m => m.BalanceInfos, CreateBalanceInfoDictionaryViewModel())
            .Create());
 }