Пример #1
0
        public void CreatePaymentTerm_WhenCalledWithoutModel_ReturnsViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = sut.CreatePaymentTerm();

            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Пример #2
0
        public void CreatePaymentTerm_WhenCalledWithoutModel_ReturnsViewResultWhereViewNameIsEqualToCreatePaymentTerm()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)sut.CreatePaymentTerm();

            Assert.That(result.ViewName, Is.EqualTo("CreatePaymentTerm"));
        }
Пример #3
0
        public async Task CreatePaymentTerm_WhenCalledWithInvalidModel_AssertPublishAsyncWasNotCalledOnCommandBus()
        {
            Controller sut = CreateSut(false);

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

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <ICreatePaymentTermCommand>()), Times.Never);
        }
Пример #4
0
        public async Task CreatePaymentTerm_WhenCalledWithValidModel_ReturnsRedirectToActionResultWhereActionNameIsEqualToPaymentTerms()
        {
            Controller sut = CreateSut();

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

            Assert.That(result.ActionName, Is.EqualTo("PaymentTerms"));
        }
Пример #5
0
        public async Task CreatePaymentTerm_WhenCalledWithValidModel_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut();

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

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
Пример #6
0
        public async Task CreatePaymentTerm_WhenCalledWithInvalidModel_ReturnsViewResultWhereViewNameIsEqualToCreatePaymentTerm()
        {
            Controller sut = CreateSut(false);

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

            Assert.That(result.ViewName, Is.EqualTo("CreatePaymentTerm"));
        }
Пример #7
0
        public async Task CreatePaymentTerm_WhenCalledWithValidModel_AssertPublishAsyncWasCalledOnCommandBus()
        {
            Controller sut = CreateSut();

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

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <ICreatePaymentTermCommand>(command =>
                                                                                         command.Number == model.Number &&
                                                                                         string.CompareOrdinal(command.Name, model.Name) == 0)),
                                   Times.Once);
        }
Пример #8
0
        public async Task CreatePaymentTerm_WhenCalledWithInvalidModel_ReturnsViewResultWhereModelIsEqualToInvalidModel()
        {
            Controller sut = CreateSut(false);

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

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

            PaymentTermViewModel paymentTermViewModel = (PaymentTermViewModel)result.Model;

            Assert.That(paymentTermViewModel, Is.EqualTo(model));
        }
Пример #9
0
        public void CreatePaymentTerm_WhenCalledWithoutModel_ReturnsViewResultWhereModelIsPaymentTermViewModel()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)sut.CreatePaymentTerm();

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

            PaymentTermViewModel paymentTermViewModel = (PaymentTermViewModel)result.Model;

            Assert.That(paymentTermViewModel, Is.Not.Null);
            Assert.That(paymentTermViewModel.Number, Is.EqualTo(default(int)));
            Assert.That(paymentTermViewModel.Name, Is.Null);
            Assert.That(paymentTermViewModel.EditMode, Is.EqualTo(EditMode.Create));
        }
Пример #10
0
        public void CreatePaymentTerm_WhenCalledWithModelWhereModelIsNull_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

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

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