コード例 #1
0
        public async Task ModificateProfilePostTest()
        {
            //Arrange
            var iExecutorService     = new Mock <IExecutorService>();
            var iUserActivityService = new Mock <IUserActivityService>();
            var mapper = new Mock <IMapper>();

            var controllerContext = new Mock <ControllerContext>();
            var controllerSession = new Mock <HttpSessionStateBase>();

            controllerContext.Setup(p => p.HttpContext.Session).Returns(controllerSession.Object);
            controllerContext.Setup(p => p.HttpContext.Session["Id"]).Returns(null);

            string             fakeInformation        = "test information";
            string             fakeCategoryFirst      = "test category";
            string             fakeCategorySecond     = fakeCategoryFirst;
            ExecutorController executorControllerTest = new ExecutorController(iExecutorService.Object,
                                                                               iUserActivityService.Object, mapper.Object);

            executorControllerTest.ControllerContext = controllerContext.Object;

            //Act
            RedirectToRouteResult redirect = await executorControllerTest.ModificateProfile(fakeInformation, fakeCategoryFirst,
                                                                                            fakeCategorySecond) as RedirectToRouteResult;

            //Asert
            Assert.AreEqual("Registration", redirect.RouteValues["action"]);
            Assert.AreEqual("Executor", redirect.RouteValues["controller"]);
        }
コード例 #2
0
        public void ModificateProfileTest()
        {
            //Arrange
            int         fakeId           = 0;
            ExecutorDTO fakeExecutorDTO  = new ExecutorDTO();
            var         iExecutorService = new Mock <IExecutorService>();

            iExecutorService.Setup(x => x.GetExecutorPropertiesForEdition(fakeId)).Returns(fakeExecutorDTO);

            var iUserActivityService = new Mock <IUserActivityService>();

            ExecutorPropertiesForEditionViewModel fakeViewModel = new ExecutorPropertiesForEditionViewModel();
            var mapper = new Mock <IMapper>();

            mapper.Setup(x => x.Map <ExecutorPropertiesForEditionViewModel>(It.IsAny <ExecutorDTO>())).Returns(fakeViewModel);

            var controllerContext = new Mock <ControllerContext>();
            var controllerSession = new Mock <HttpSessionStateBase>();

            controllerContext.Setup(p => p.HttpContext.Session).Returns(controllerSession.Object);
            controllerContext.Setup(p => p.HttpContext.Session["Id"]).Returns(fakeId);

            ExecutorController executorControllerTest = new ExecutorController(iExecutorService.Object,
                                                                               iUserActivityService.Object, mapper.Object);

            executorControllerTest.ControllerContext = controllerContext.Object;

            //Act
            ViewResult view = executorControllerTest.ModificateProfile() as ViewResult;

            //Asert
            Assert.IsNotNull(view);
            Assert.IsNotNull(view.Model);
        }