コード例 #1
0
        public void AddAddressGetTest()
        {
            var controller = new AccountsController();
            var result     = (PartialViewResult)controller.AddAddress();

            Assert.IsInstanceOfType(result, typeof(PartialViewResult));
            Assert.AreEqual("AddAddress", result.ViewName);
        }
コード例 #2
0
        public void AddAddressExceptionTest()
        {
            var mockMemberDal = new MockMemberDal()
            {
                ThrowError = true
            };
            var controller = new AccountsController(mockMemberDal, new MockRentalDal());
            var result     = (ViewResult)controller.AddAddress(new Address());

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("Profile", result.ViewName);
            Assert.AreEqual("Uh-oh something went wrong", result.ViewData["Error"]);
        }
コード例 #3
0
        public void AddAddressValidTest()
        {
            HomeController.CurrentUser = new Member();
            var mockMemberDal = new MockMemberDal()
            {
                ThrowError = false
            };
            var controller = new AccountsController(mockMemberDal, new MockRentalDal());
            var result     = (ViewResult)controller.AddAddress(new Address());

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("Profile", result.ViewName);
        }
コード例 #4
0
        public void AddAddressInvalidTest()
        {
            var mockMemberDal = new MockMemberDal()
            {
                ThrowError = false
            };
            var controller = new AccountsController(mockMemberDal, new MockRentalDal());

            controller.ModelState.AddModelError("error", "error");
            var result = (ViewResult)controller.AddAddress(new Address());

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("Profile", result.ViewName);
            Assert.AreEqual("Invalid Address", result.ViewData["Error"]);
        }