public void CanCreate()
        {
            var courseToCreateDto = new CourseDto { Name = "Bakken" };
            var createdCourse = new Course { Id = 1, Name = courseToCreateDto.Name };

            _courseRepository.Create(Arg.Any<Course>()).Returns(createdCourse);

            var createdCourseDto = _courseFacade.Create(courseToCreateDto);

            _courseRepository.Received().Create(Arg.Any<Course>());
            Assert.NotNull(createdCourseDto);
            Assert.Equal(createdCourse.Id, createdCourseDto.Id);
        }
        public void CanGet()
        {
            var course = new Course { Id = 1, Name = "Bakken" };

            _courseRepository.Get(course.Id).Returns(course);

            var foundCourse = _courseFacade.Get(course.Id);

            _courseRepository.Received().Get(course.Id);
            Assert.NotNull(foundCourse);
            Assert.Equal(course.Id, foundCourse.Id);
            Assert.Equal(course.Name, foundCourse.Name);
        }
        public void CanUpdate()
        {
            var updatedCourse = new Course { Id = 1, Name = "Bakken" };
            var courseToUpdateDto = new CourseDto { Id = updatedCourse.Id, Name = updatedCourse.Name };

            _courseRepository.Update(Arg.Any<Course>()).Returns(updatedCourse);

            var updatedCourseDto = _courseFacade.Update(courseToUpdateDto);

            _courseRepository.Received().Update(Arg.Any<Course>());
            Assert.NotNull(updatedCourseDto);
            Assert.Equal(updatedCourseDto.Id, updatedCourseDto.Id);
            Assert.Equal(updatedCourseDto.Name, updatedCourseDto.Name);
        }
        public void CanCreate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var course = new Course
                {
                    Name = "Snijden"
                };

                var createdCourse = new CourseRepository(dbContext).Create(course);

                Assert.NotNull(createdCourse);
                Assert.True(createdCourse.Id > 0);
                Assert.Equal(course.Name, createdCourse.Name);
            });
        }
        public void CanGet()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var course1 = new Course
                {
                    Name = "Snijden"
                };

                var course2 = new Course
                {
                    Name = "Bakken"
                };

                dbContext.Courses.Add(course1);
                dbContext.Courses.Add(course2);
                dbContext.SaveChanges();

                var course = new CourseRepository(dbContext).Get(course2.Id);

                Assert.NotNull(course);
                Assert.Equal(course2.Id, course.Id);
            });
        }
        public void CanUpdate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var updatedName = "Koken";

                var course = new Course
                {
                    Name = "Snijden"
                };

                dbContext.Courses.Add(course);
                dbContext.SaveChanges();

                course.Name = updatedName;
                var updatedCourse = new CourseRepository(dbContext).Update(course);

                Assert.NotNull(updatedCourse);
                Assert.Equal(course.Id, updatedCourse.Id);
                Assert.Equal(updatedName, updatedCourse.Name);
            });
        }
        public void CanDelete()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var course1 = new Course
                {
                    Name = "Snijden"
                };

                var course2 = new Course
                {
                    Name = "Bakken"
                };

                dbContext.Courses.Add(course1);
                dbContext.Courses.Add(course2);
                dbContext.SaveChanges();

                new CourseRepository(dbContext).Delete(course1.Id);

                Assert.Equal(1, dbContext.Courses.Count());
                Assert.Equal(course2.Id, dbContext.Courses.First().Id);
            });
        }