Ejemplo n.º 1
0
        public void CanUpdateUserRating()
        {
            DbContextOptions <SwitchbackAPIDbContext> options = new DbContextOptionsBuilder <SwitchbackAPIDbContext>().UseInMemoryDatabase("CanCreateCourse").Options;

            using (SwitchbackAPIDbContext context = new SwitchbackAPIDbContext(options))
            {
                // Arrange
                UserRatings rating11 = new UserRatings();
                rating11.ID          = 11;
                rating11.TrailInfoID = 1;
                rating11.Rating      = 4;


                context.Add(rating11);
                context.SaveChanges();

                rating11.Rating = 5;
                context.Update(rating11);
                context.SaveChanges();

                // Act
                var result = context.UserRatings.FirstOrDefault(m => m.ID == rating11.ID);

                // Assert

                Assert.Equal(result, rating11);
            };
        }
Ejemplo n.º 2
0
        public void CanGetUpdateTrail()
        {
            DbContextOptions <SwitchbackAPIDbContext> options = new DbContextOptionsBuilder <SwitchbackAPIDbContext>().UseInMemoryDatabase("CanCreateCourse").Options;

            using (SwitchbackAPIDbContext context = new SwitchbackAPIDbContext(options))
            {
                // Arrange
                Trail trail1 = new Trail();
                trail1.Name             = "Clown Lake Trail";
                trail1.Type             = "Featured Hike";
                trail1.Summary          = "A great place for a picnic and watching paragliders!";
                trail1.Difficulty       = "blue";
                trail1.Stars            = 4.3;
                trail1.StarVotes        = 50;
                trail1.Location         = "Issaquah, Washington";
                trail1.Url              = "https://www.hikingproject.com/trail/7005406/poo-poo-point-via-chirico-trail";
                trail1.ImgSqSmall       = "https://cdn-files.apstatic.com/hike/7004771_sqsmall_1554310760.jpg";
                trail1.ImgSmall         = "https://cdn-files.apstatic.com/hike/7004771_small_1554310760.jpg";
                trail1.ImgSmallMed      = "https://cdn-files.apstatic.com/hike/7004771_smallMed_1554310760.jpg";
                trail1.ImgMedium        = "https://cdn-files.apstatic.com/hike/7004771_medium_1554310760.jpg";
                trail1.Length           = 3.9;
                trail1.Ascent           = 1619;
                trail1.Descent          = -1618;
                trail1.High             = 1807;
                trail1.Low              = 188;
                trail1.Longitude        = -122.0211;
                trail1.Latitude         = 47.4999;
                trail1.ConditionStatus  = "All Clear";
                trail1.ConditionDetails = "Dry";
                trail1.ConditionDate    = "2019-04-19 11:05:03";

                context.Add(trail1);
                context.SaveChanges();

                trail1.ConditionStatus = "Raining Cats and Dogs";
                context.Update(trail1);
                context.SaveChanges();

                // Act
                var result = context.Trail.FirstOrDefault(m => m.TrailID == trail1.TrailID);

                // Assert

                Assert.Equal(result, trail1);
            };
        }