public void CanGetAllLocations() { DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetAllLocations").Options; using (RimRockApiDbContext context = new RimRockApiDbContext(options)) { // Arrange Location location1 = new Location(); location1.ID = 1; location1.Name = "Mt. Baker"; context.Add(location1); context.SaveChanges(); Location location2 = new Location(); location2.ID = 2; location2.Name = "Mt. St. Helens"; context.Add(location2); context.SaveChanges(); // Act List <Location> list = context.Locations.ToList(); // Assert Assert.Equal(list[1], location2); }; }
public void CanGetAllRetailers() { DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetAllRetailers").Options; using (RimRockApiDbContext context = new RimRockApiDbContext(options)) { // Arrange Retailer retailer1 = new Retailer(); retailer1.ID = 1; retailer1.Name = "Second Ascents"; context.Add(retailer1); context.SaveChanges(); Retailer retailer2 = new Retailer(); retailer2.ID = 2; retailer2.Name = "Play It Again Sports"; context.Add(retailer2); context.SaveChanges(); // Act List <Retailer> list = context.Retailers.ToList(); // Assert Assert.Equal(list[1], retailer2); }; }
public void CanGetAllRegions() { DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetAllRegions").Options; using (RimRockApiDbContext context = new RimRockApiDbContext(options)) { // Arrange Region region1 = new Region(); region1.ID = 1; region1.Name = "Paris"; context.Add(region1); context.SaveChanges(); Region region2 = new Region(); region2.ID = 2; region2.Name = "Bretagne"; context.Add(region2); context.SaveChanges(); // Act List <Region> list = context.Regions.ToList(); // Assert Assert.Equal(list[1], region2); }; }
public void CanGetRegion() { DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetRegion").Options; using (RimRockApiDbContext context = new RimRockApiDbContext(options)) { // Arrange Region region = new Region(); region.ID = 1; region.Name = "Paris"; context.Add(region); context.SaveChanges(); // Act var result = context.Regions.FirstOrDefault(r => r.Name == region.Name); // Assert Assert.Equal(result, region); }; }
public void CanGetLocation() { DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetLocation").Options; using (RimRockApiDbContext context = new RimRockApiDbContext(options)) { // Arrange Location location = new Location(); location.ID = 1; location.Name = "Second Ascents"; location.Cost = "$$"; context.Add(location); context.SaveChanges(); // Act var result = context.Locations.FirstOrDefault(loc => loc.Cost == location.Cost); // Assert Assert.Equal(result, location); }; }
public void CanGetRetailer() { DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetRetailer").Options; using (RimRockApiDbContext context = new RimRockApiDbContext(options)) { // Arrange Retailer retailer = new Retailer(); retailer.ID = 1; retailer.Name = "Second Ascents"; retailer.Specialty = "Alpine climbing"; context.Add(retailer); context.SaveChanges(); // Act var result = context.Retailers.FirstOrDefault(r => r.Specialty == retailer.Specialty); // Assert Assert.Equal(result, retailer); }; }