Exemple #1
0
        public async Task UpdatePaymentTerm_WhenCalledWithNumber_ReturnsViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.UpdatePaymentTerm(_fixture.Create <int>());

            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Exemple #2
0
        public async Task UpdatePaymentTerm_WhenCalledWithNumber_ReturnsViewResultWhereViewNameIsEqualToUpdatePaymentTerm()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)await sut.UpdatePaymentTerm(_fixture.Create <int>());

            Assert.That(result.ViewName, Is.EqualTo("UpdatePaymentTerm"));
        }
Exemple #3
0
        public async Task UpdatePaymentTerm_WhenCalledWithValidModel_ReturnsRedirectToActionResultWhereActionNameIsEqualToPaymentTerms()
        {
            Controller sut = CreateSut();

            PaymentTermViewModel   model  = CreateModel();
            RedirectToActionResult result = (RedirectToActionResult)await sut.UpdatePaymentTerm(model);

            Assert.That(result.ActionName, Is.EqualTo("PaymentTerms"));
        }
Exemple #4
0
        public async Task UpdatePaymentTerm_WhenCalledWithNumber_AssertQueryAsyncWasCalledOnQueryBus()
        {
            Controller sut = CreateSut();

            int number = _fixture.Create <int>();
            await sut.UpdatePaymentTerm(number);

            _queryBusMock.Verify(m => m.QueryAsync <IGetPaymentTermQuery, IPaymentTerm>(It.Is <IGetPaymentTermQuery>(value => value.Number == number)), Times.Once);
        }
Exemple #5
0
        public async Task UpdatePaymentTerm_WhenCalledWithValidModel_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut();

            PaymentTermViewModel model  = CreateModel();
            IActionResult        result = await sut.UpdatePaymentTerm(model);

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
Exemple #6
0
        public async Task UpdatePaymentTerm_WhenCalledWithValidModel_AssertPublishAsyncWasCalledOnCommandBus()
        {
            Controller sut = CreateSut();

            PaymentTermViewModel model = CreateModel();
            await sut.UpdatePaymentTerm(model);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdatePaymentTermCommand>(command => command.Number == model.Number && string.CompareOrdinal(command.Name, model.Name) == 0)), Times.Once);
        }
Exemple #7
0
        public async Task UpdatePaymentTerm_WhenCalledWithInvalidModel_ReturnsViewResultWhereViewNameIsEqualToUpdatePaymentTerm()
        {
            Controller sut = CreateSut(modelIsValid: false);

            PaymentTermViewModel model  = CreateModel();
            ViewResult           result = (ViewResult)await sut.UpdatePaymentTerm(model);

            Assert.That(result.ViewName, Is.EqualTo("UpdatePaymentTerm"));
        }
Exemple #8
0
        public async Task UpdatePaymentTerm_WhenCalledWithInvalidModel_AssertPublishAsyncWasNotCalledOnCommandBus()
        {
            Controller sut = CreateSut(modelIsValid: false);

            PaymentTermViewModel model = CreateModel();
            await sut.UpdatePaymentTerm(model);

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IUpdatePaymentTermCommand>()), Times.Never);
        }
Exemple #9
0
        public async Task UpdatePaymentTerm_WhenCalledWithInvalidModel_ReturnsViewResultWhereModelIsEqualToInvalidModel()
        {
            Controller sut = CreateSut(modelIsValid: false);

            PaymentTermViewModel model  = CreateModel();
            ViewResult           result = (ViewResult)await sut.UpdatePaymentTerm(model);

            Assert.That(result.Model, Is.TypeOf <PaymentTermViewModel>());

            PaymentTermViewModel paymentTermViewModel = (PaymentTermViewModel)result.Model;

            Assert.That(paymentTermViewModel, Is.EqualTo(model));
        }
Exemple #10
0
        public async Task UpdatePaymentTerm_WhenCalledWithNumber_ReturnsViewResultWhereModelIsPaymentTermViewModel()
        {
            int          number      = _fixture.Create <int>();
            string       name        = _fixture.Create <string>();
            IPaymentTerm paymentTerm = _fixture.BuildPaymentTermMock(number, name).Object;
            Controller   sut         = CreateSut(paymentTerm);

            ViewResult result = (ViewResult)await sut.UpdatePaymentTerm(_fixture.Create <int>());

            Assert.That(result.Model, Is.TypeOf <PaymentTermViewModel>());

            PaymentTermViewModel paymentTermViewModel = (PaymentTermViewModel)result.Model;

            Assert.That(paymentTermViewModel, Is.Not.Null);
            Assert.That(paymentTermViewModel.Number, Is.EqualTo(number));
            Assert.That(paymentTermViewModel.Name, Is.EqualTo(name));
            Assert.That(paymentTermViewModel.EditMode, Is.EqualTo(EditMode.Edit));
        }
Exemple #11
0
        public void UpdatePaymentTerm_WhenCalledWithModelWhereModelIsNull_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdatePaymentTerm(null));

            Assert.That(result.ParamName, Is.EqualTo("paymentTermViewModel"));
        }