Ejemplo n.º 1
0
        public void GetAllRatingsForDentist_WithInvalidRatings_ShouldReturnEmptyRatingsCollection()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);

            var rating = new Rating
            {
                Id              = 1,
                DentistId       = "1",
                RatingByPatient = 10
            };

            var rating2 = new Rating
            {
                Id              = 2,
                DentistId       = "2",
                RatingByPatient = 0
            };

            dbContext.Ratings.Add(rating);
            dbContext.Ratings.Add(rating2);
            dbContext.SaveChanges();

            var ratingRepository = new DbRepository <Rating>(dbContext);
            var service          = new RatingService(ratingRepository);
            var result           = service.GetAllRatingsForDentist("2");

            Assert.Empty(result);
        }