Ejemplo n.º 1
0
        public void DetailsTest()
        {
            string email = "/////////";

            var result = (ViewResult)controller.Details(email) as ViewResult;

            Assert.IsNotNull(result);
        }
        public void ShouldRenderDetailViewCorrectly()
        {
            Mock <IGenericService <Teacher> > teacherServiceMock = new Mock <IGenericService <Teacher> >();

            Teacher teacher = new Teacher()
            {
                Id        = 100,
                FirstName = "Robin",
                LastName  = "Schellius"
            };

            teacherServiceMock.Setup(m => m.FindById(It.IsAny <int>(), It.IsAny <string[]>())).Returns(teacher);

            TeacherController controller = new TeacherController(teacherServiceMock.Object);
            Teacher           model      = (controller.Details(teacher.Id) as ViewResult)?.ViewData.Model as Teacher;

            Assert.Equal(100, model.Id);
            Assert.Equal("Robin Schellius", model.FullName);
        }
        public async void Details_WhenIdIsNull_ReturnsNotFound()
        {
            var result = await systemUnderTest.Details(null);

            Assert.IsType <NotFoundResult>(result);
        }