Esempio n. 1
0
        public void ReturnViewForEditWithoutVendor()
        {
            _mockVendorRepo.Setup(x => x.GetById(It.IsAny <int>())).Returns((Vendor)null);

            _sut = new VendorsController(_mockVendorRepo.Object);

            IActionResult redirectToActionResult = _sut.EditVendor(1);

            Assert.IsType <RedirectToActionResult>(redirectToActionResult);
        }
Esempio n. 2
0
        public void NotSaveToDatabaseWithModelError()
        {
            _mockVendorRepo.Setup(x => x.GetById(It.IsAny <int>())).Returns(_vendor1);

            var model = new VendorEditViewModel();

            _sut = new VendorsController(_mockVendorRepo.Object);

            _sut.ModelState.AddModelError("x", "Test Error");

            _sut.EditVendor(1, model);

            _mockVendorRepo.Verify(x => x.Commit(), Times.Never);
        }
Esempio n. 3
0
        public void CommitToDatabaseWithValidVendorEdit()
        {
            _mockVendorRepo.Setup(x => x.GetById(It.IsAny <int>())).Returns(_vendor2);

            var model = new VendorEditViewModel()
            {
                VendorName   = "New Name",
                VendorNumber = 201,
                Description  = "New Description",
                Status       = VendorStatus.NonTaxable
            };

            _sut = new VendorsController(_mockVendorRepo.Object);

            _sut.EditVendor(1, model);

            _mockVendorRepo.Verify(x => x.Commit(), Times.Once);
        }