public async Task AddAndSaveTest()
        {
            var course1 = new Course()
            {
                Id = 1, Name = "test course 1", CoachId = 1, RoomId = 1
            };
            var course2 = new Course()
            {
                Id = 2, Name = "test course 2", CoachId = 2, RoomId = 2
            };
            var courses = new List <Course> {
                course1, course2
            };

            var course3 = new Course()
            {
                Id = 3, Name = "test course 3", CoachId = 3, RoomId = 3
            };

            var fakeCourseRepositoryMock = new Mock <ICourseRepository>();
            var fakeCoachRepositoryMock = new Mock <ICoachRepository>(); var fakeRoomRepositoryMock = new Mock <IRoomRepository>();

            fakeCourseRepositoryMock.Setup(x => x.Add(It.IsAny <Course>())).Callback <Course>(arg => courses.Add(arg));

            var courseService = new CourseService(fakeCourseRepositoryMock.Object, fakeCoachRepositoryMock.Object, fakeRoomRepositoryMock.Object);

            await courseService.AddAndSave(course3);


            Assert.Equal(3, courses.Count);
        }
        public async Task <IActionResult> Create([Bind("Id,Name,CoachId,RoomId")] Course course)
        {
            if (ModelState.IsValid)
            {
                await _courseService.AddAndSave(course);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CoachId"] = new SelectList(await _courseService.GetAllCoaches(), "Id", "Name", course.CoachId);
            ViewData["RoomId"]  = new SelectList(await _courseService.GetAllRooms(), "Id", "Id", course.RoomId);
            return(View(course));
        }