Beispiel #1
0
        public void SaveAndReload()
        {
            // Run the test against one instance of the context
            using (var context = new MyDbContext(options))
            {
                var myController = new HomeController(context);
                myController.Save(new EfCoreUnitTest_Test.Models.HomeModel
                {
                    Foo = "Hello"
                });
            }

            using (var context = new MyDbContext(options))
            {
                var myController = new HomeController(context);
                var indexResult  = myController.Index();
                var viewResult   = indexResult.Should().BeOfType <ViewResult>();
                var model        = viewResult.Subject.Model.Should().BeOfType <HomeModel>();
                model.Subject.Foo.Should().Be("Hello");
            }
        }