예제 #1
0
        public async Task IndexPostValidModel()
        {
            //arrange
            PersonalDataController personalDataController
                = new PersonalDataController(Mocks.GetAddressRepository(), Mocks.GetMapper(), Mocks.GetMockUserManager());

            Mocks.FillController(personalDataController);

            //act
            IActionResult result = await personalDataController.Index(new AddressDataViewModel());

            //assert
            Assert.AreEqual(typeof(RedirectToActionResult), result.GetType());
        }
예제 #2
0
        public async Task IndexGet()
        {
            //arrange
            PersonalDataController personalDataController
                = new PersonalDataController(Mocks.GetAddressRepository(), Mocks.GetMapper(), Mocks.GetMockUserManager());

            Mocks.FillController(personalDataController);

            //act
            IActionResult result = await personalDataController.Index();

            //assert
            Assert.AreEqual(typeof(ViewResult), result.GetType());
            ViewResult viewResult = (ViewResult)result;

            Assert.AreEqual(typeof(AccountDataViewModel), viewResult.Model.GetType());
        }
예제 #3
0
        public async Task IndexPostInvalidModel()
        {
            //arrange
            PersonalDataController personalDataController
                = new PersonalDataController(Mocks.GetAddressRepository(), Mocks.GetMapper(), Mocks.GetMockUserManager());

            Mocks.FillController(personalDataController);
            personalDataController.ModelState.AddModelError("", "");

            //act
            IActionResult result = await personalDataController.Index(new AddressDataViewModel());

            //assert
            Assert.AreEqual(typeof(ViewResult), result.GetType());
            ViewResult viewResult = (ViewResult)result;

            Assert.AreEqual(typeof(AddressDataViewModel), viewResult.Model.GetType());
        }