Exemplo n.º 1
0
        public async Task Create_WithoutParameters_ShouldCallService()
        {
            bool isCalledService = false;

            var mockDaysService = new Mock <IDaysService>();

            mockDaysService
            .Setup(opt => opt.CreateDayAsync(It.IsAny <string>()))
            .Callback(() => isCalledService = true)
            .ReturnsAsync(() => 0);
            var mockTrainngsService        = new Mock <ITrainingsService>();
            var mockTrainerProgramsService = new Mock <ITrainersProgramsService>();

            var controller = new DaysController(
                mockDaysService.Object,
                mockTrainngsService.Object,
                mockTrainerProgramsService.Object)
            {
                ControllerContext = this.controllerContext
            };

            var result = await controller.Create();

            Assert.IsTrue(isCalledService);
        }
Exemplo n.º 2
0
        public async Task Create_WithoutParameters_ShouldRedirectToCorrectAction()
        {
            DaysController controller = GetDaysController();

            var result = await controller.Create();

            Assert.AreEqual(ActionConstants.Details, ((RedirectToActionResult)result).ActionName);
            Assert.AreEqual(ControllerConstants.Days, ((RedirectToActionResult)result).ControllerName);
        }