예제 #1
0
        public async void TestIndexMethod_ReturnViewWithObjects()
        {
            // Arrange
            var mockDanceRepo = new Mock <IDanceRepository>();

            mockDanceRepo.Setup(repo => repo.FindDanceCourseType(""))
            .Returns(Task.FromResult(DataTestService.FindTestCoursesList()));

            var controller = new DanceCourseTypesController(mockDanceRepo.Object);

            // Act
            var result = await controller.Index("");

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.NotNull(viewResult);

            var model = Assert.IsAssignableFrom <List <DanceCourseTypeVM> >(viewResult.ViewData.Model);

            Assert.Equal(2, model.Count);
        }
예제 #2
0
        public async void TestGetDanceCourseTypesMethodReturnObjects()
        {
            // Arrange
            var mockRepo = new Mock <IDanceRepository>();

            mockRepo.Setup(repo => repo.GetDanceCourseTypes())
            .Returns(Task.FromResult(DataTestService.GetTestCoursesList()));

            var controller = new DanceController(mockRepo.Object);

            // Act
            var result = await controller.GetDanceCourseTypes();

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);

            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);

            var model = Assert.IsAssignableFrom <List <DanceCourseType> >(okResult.Value);

            Assert.Equal(2, model.Count);
        }