Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
 public ContinentsController(MondialContext context)
 {
     _context = context;
 }
Exemplo n.º 3
0
 public WorldController(MondialContext context, World world)
 {
     _context   = context;
     this.world = world;
 }