コード例 #1
0
        public void StuffStartsHere()
        {
            _context = new DevLunchDbContext(Effort.DbConnectionFactory.CreateTransient());

            _controller = new LunchesController(_context);
            _controller.WithAuthenticatedUser("Brent", "ImBrent");

            _lunch = new Lunch()
            {
                Host        = "Brent",
                MeetingTime = new DateTime(1985, 6, 6),
                Restaurants = new List <Restaurant>()
                {
                    new Restaurant {
                        Name = "Linda's", Latitude = 55, Longitude = 60
                    },
                    new Restaurant {
                        Name = "The Pine Box", Latitude = 55, Longitude = 60
                    },
                    new Restaurant {
                        Name = "Sizzler", Latitude = 55, Longitude = 60
                    }
                }
            };

            _context.Lunches.Add(_lunch);
            _context.SaveChanges();

            _lunchId       = _lunch.Id;
            _restaurantId1 = _lunch.Restaurants.First().Id;
            _restaurantId2 = _lunch.Restaurants.FirstOrDefault(r => r.Name == "The Pine Box").Id;
            _restaurantId3 = _lunch.Restaurants.Last().Id;
        }
コード例 #2
0
        public void Edit_Get_ThrowsNotFoundIfRestaurantNotInDb()
        {
            var _context   = new DevLunchDbContext(Effort.DbConnectionFactory.CreateTransient());
            var controller = new RestaurantController(_context);

            // Act
            var result = controller.Details(999) as HttpStatusCodeResult;

            // Assert
            result.ShouldBeOfType <HttpNotFoundResult>();
            result.StatusCode.ShouldBe(404);
        }
コード例 #3
0
        protected override void Seed(DevLunchDbContext context)
        {
            context.Votes.RemoveRange(context.Votes);
            context.Restaurants.RemoveRange(context.Restaurants);
            context.Lunches.RemoveRange(context.Lunches);

            var restaurants = new List <Restaurant>
            {
                new Restaurant {
                    Name = "Rocco’s"
                },
                new Restaurant {
                    Name = "Li’l Woody’s"
                },
                new Restaurant {
                    Name = "Biscuit Bitch Belltown"
                },
                new Restaurant {
                    Name = "Lunchbox Laboratory"
                },
                new Restaurant {
                    Name = "Citrus Thai Cuisine"
                },
                new Restaurant {
                    Name = "Icon Grill"
                },
                new Restaurant {
                    Name = "FareStart"
                },
                new Restaurant {
                    Name = "Gordon Biersch"
                },
                new Restaurant {
                    Name = "Dahlia Lounge"
                },
                new Restaurant {
                    Name = "Cactus"
                },
                new Restaurant {
                    Name = "Blue Moon Burgers"
                },
                new Restaurant {
                    Name = "Serious Pie"
                },
                new Restaurant {
                    Name = "Brave Horse Tavern"
                }
            };

            context.Restaurants.AddRange(restaurants);
            context.SaveChanges();
        }
コード例 #4
0
 public void StuffStartsHere()
 {
     _context = new DevLunchDbContext(Effort.DbConnectionFactory.CreateTransient());
 }
コード例 #5
0
 public LunchesController(DevLunchDbContext context)
 {
     _context = context;
 }
コード例 #6
0
 public RestaurantController(DevLunchDbContext context)
 {
     _context = context;
 }