public async Task Test2() { var hc = new HomeController(); Assert.IsTrue(hc.Index() is ViewResult); DbContextOptions <MondialContext> options; var builder = new DbContextOptionsBuilder <MondialContext>(); builder.UseInMemoryDatabase("Mondial"); options = builder.Options; using (MondialContext mondialContext = new MondialContext(options)) { mondialContext.Continents.Add(new Continent { Name = "Lummerland", Area = 55 }); mondialContext.Continents.Add(new Continent { Name = "Pangea", Area = 525252 }); mondialContext.SaveChanges(); World world = new World(mondialContext); var continents = await world.GetContinentsAsync(); Assert.IsTrue(continents.Count() == 2); Assert.IsTrue(continents.First().Name == "Lummerland"); WorldController worldController = new WorldController(world); var vr = (await worldController.Index()) as ViewResult; //Assert.IsInstanceOfType(view, typeof(ViewResult)); Assert.IsNotNull(vr); var model = vr.Model as IEnumerable <Continent>; Assert.IsNotNull(model); Assert.IsTrue(model.Last().Name == "Pangea"); } }
public ContinentsController(MondialContext context) { _context = context; }
public WorldController(MondialContext context, World world) { _context = context; this.world = world; }