Esempio n. 1
0
 public void GetAvgRatingTest()
 {
     try
     {
         DbLocation dbLocation = new DbLocation();
         DbRating   dbRating   = new DbRating();
         Location   location   = new Location
         {
             Latitude            = 1,
             Longitude           = 1,
             LocationName        = "AVGTEST",
             LocationDescription = "AVGDescription"
         };
         int    id      = dbLocation.Create(location);
         Rating rating1 = new Rating
         {
             LocationId = id,
             Rate       = 1,
             Comment    = "RateTest1"
         };
         Rating rating2 = new Rating
         {
             LocationId = id,
             Rate       = 5,
             Comment    = "RateTest2"
         };
         rating1.RatingId = dbRating.Create(rating1);
         rating2.RatingId = dbRating.Create(rating2);
         double rate = dbRating.GetAverageRating(id);
         Assert.IsTrue(rate == 3);
         dbRating.Delete(rating1);
         dbRating.Delete(rating2);
         dbLocation.Delete(id);
     }
     catch (FaultException <System.Exception> )
     {
         Assert.Fail();
     }
 }
Esempio n. 2
0
        public void CreateRatingTest()
        {
            DbRating dbRating = new DbRating();

            try
            {
                Rating rating = new Rating
                {
                    Rate       = 4,
                    Comment    = "Hej",
                    LocationId = 5,
                    User       = new User {
                        UserId = 2
                    }
                };

                int ratingId = dbRating.Create(rating);
                Assert.IsTrue(ratingId > 0);
            }
            catch (FaultException <DbConnectionException> )
            {
                Assert.Fail();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Create a rating in database
 /// </summary>
 /// <param name="rating">Rating</param>
 /// <returns>int</returns>
 public int CreateRating(Rating rating)
 {
     return(_dbRating.Create(rating));
 }
Esempio n. 4
0
        public async Task CreateAsync(Rating rating)
        {
            await _context.Ratings.AddAsync(DbRating.Create(rating));

            await _context.SaveChangesAsync();
        }