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

            var rating2 = new Rating
            {
                Id              = 2,
                DentistId       = "1",
                PatientId       = "1",
                RatingByDentist = 9
            };

            var rating3 = new Rating
            {
                Id              = 3,
                DentistId       = "1",
                PatientId       = "1",
                RatingByDentist = 0
            };

            var rating4 = new Rating
            {
                Id              = 4,
                DentistId       = "1",
                PatientId       = "2",
                RatingByDentist = 10
            };

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

            var ratingRepository = new DbRepository <Rating>(dbContext);
            var service          = new RatingService(ratingRepository);
            var result           = service.GetAllRatingsForPatientByDentist("1", "1");

            Assert.Equal(new Rating[] { rating, rating2 }, result);
        }