public async Task Index_Returns_ViewResult()
        {
            IFixture fixture = new Fixture();

            fixture.Behaviors.Add(new OmitOnRecursionBehavior());
            var model = fixture.Create <DoctorsViewModel>();

            _appService.Setup(c =>
                              c.GetDoctorsAppointmentsForDay(It.IsAny <string>(), It.IsAny <DateTime>(), CancellationToken.None))
            .ReturnsAsync(model);

            var appointmentsController = new DoctorsController(_appService.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext
                    {
                        User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "user") },
                                                                      "test"))
                    }
                }
            };

            var action = await appointmentsController.Index();

            Assert.IsInstanceOf <ViewResult>(action);
        }
示例#2
0
        //[TestMethod]
        //[TestCategory("Index")]
        public void ShouldCheckResultFromDoctorsControllerIndexIsNotNull()
        {
            _doctorsController = new DoctorsController(_doctorRepository);

            var value = _doctorsController.Index() as ViewResult;

            Assert.IsNotNull(value);
        }
        public void Index()
        {
            // Arrange
            DoctorsController controller = new DoctorsController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }