public void course_material_should_have_rating_when_have_been_rated()
        {
            var repo = Substitute.For <ICourseMaterialRepository>();

            repo
            .GetRatingsFor(5)
            .Returns(new []
            {
                new CourseMaterialUserRanting
                {
                    CourseMaterialId = 5,
                    Rating           = 1
                },
                new CourseMaterialUserRanting
                {
                    CourseMaterialId = 5,
                    Rating           = 5
                }
            }
                     );

            repo.GetBy(5).Returns(new CourseMaterial
            {
                Title   = "aMaterial",
                Rating  = 0,
                Content = "aContent",
                Id      = 5
            });

            var service = new CourseMaterialService(repo);

            var cm = service.GetBy(5);

            cm.Rating.Should().Be(3);
        }
        public void service_should_return_null_when_cm_not_found()
        {
            var repo    = Substitute.For <ICourseMaterialRepository>();
            var service = new CourseMaterialService(repo);

            var cm = service.GetBy(5);

            cm.Should().BeNull();
        }
        public void course_material_should_have_rating_cero_when_no_ratings()
        {
            var repo = Substitute.For <ICourseMaterialRepository>();

            repo.GetBy(5).Returns(new CourseMaterial
            {
                Title   = "aMaterial",
                Rating  = 0,
                Content = "aContent",
                Id      = 5
            });

            var service = new CourseMaterialService(repo);

            var cm = service.GetBy(5);

            cm.Rating.Should().Be(0);
            cm.Title.Should().Be("aMaterial");
            cm.Content.Should().Be("aContent");
        }