Пример #1
0
        public void GetAllRatingsForPatient_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,
                PatientId       = "1",
                RatingByDentist = 10
            };

            var rating2 = new Rating
            {
                Id              = 2,
                PatientId       = "2",
                RatingByDentist = 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.GetAllRatingsForPatient("2");

            Assert.Empty(result);
        }