Пример #1
0
        public void Details_Has_A_View()
        {
            int id     = 1;
            var result = underTest.Details(id);

            Assert.IsType <ViewResult>(result);
        }
Пример #2
0
        public void Details_Returns_A_View()
        {
            // Act
            var result = controller.Details(1);

            // Assert
            Assert.IsType <ViewResult>(result);
        }
        public void TestDetails(string id)
        {
            _mockCourseAccessLayer.Setup(x => x.GetCourse(new Guid(id))).Returns(new Course()
            {
                Id            = new Guid("00000000-0000-0000-0000-000000000001"),
                Name          = "Point Walter",
                Created       = _createdAt,
                Holes         = "1-9",
                Location      = "Western Australia",
                Par           = 35,
                ScratchRating = 34,
                Slope         = 115,
                TeeName       = "Blue Men"
            });

            var expected = new Course()
            {
                Id            = new Guid("00000000-0000-0000-0000-000000000001"),
                Name          = "Point Walter",
                Created       = _createdAt,
                Holes         = "1-9",
                Location      = "Western Australia",
                Par           = 35,
                ScratchRating = 34,
                Slope         = 115,
                TeeName       = "Blue Men"
            };
            var actual = _sut.Details(new Guid(id)) as ObjectResult;

            actual.StatusCode.Should().Be(200);
            actual.Value.Should().BeEquivalentTo(expected);
        }
Пример #4
0
        public void ShouldRenderDetailViewCorrectly()
        {
            Mock <IGenericService <Course> > courseServiceMock = new Mock <IGenericService <Course> >();

            Course course = new Course()
            {
                Id          = 100,
                Name        = "Periode 2.3 Data Science",
                Description = "Alle opdrachten in deze periode zijn gekoppeld aan vakken; dit kunnen individuele of groepsopdrachten zijn; er zijn geen opdrachten die meerdere vakken betreffen. Daarom is een verdere omschrijving hier niet nodig."
            };

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

            CourseController controller = new CourseController(courseServiceMock.Object, null, null, null, null, null);
            Course           model      = (controller.Details(course.Id) as ViewResult)?.ViewData.Model as Course;

            Assert.Equal(100, model.Id);
            Assert.Equal("Periode 2.3 Data Science", model.Name);
        }
        public void Get_if_not_author_and_not_admin_then_redirects_to_noacces_view()
        {
            #region Arrange

            using (Mock.Record())
            {
                Expect.Call(CourseService.GetById(1)).Return(Course);
            }
            #endregion

            #region Act
            ViewResult view;
            using (Mock.Playback())
            {
                view = (ViewResult)CourseController.Details(1);
            }

            #endregion

            #region Assert
            Assert.IsEmpty(view.ViewName);
            Assert.That(view.ViewData.Model, Is.InstanceOf(typeof(CourseDto)));
            #endregion
        }
Пример #6
0
        public void Details_Returns_A_View()
        {
            var result = sut.Details(1);

            Assert.IsType <ViewResult>(result);
        }