示例#1
0
        public void Throws_on_attempt_to_use_store_with_no_store_services()
        {
            var serviceProvider = new ServiceCollection().AddEntityFramework().BuildServiceProvider();

            Assert.Equal(
                CoreStrings.NoProviderConfigured,
                Assert.Throws <InvalidOperationException>(() =>
            {
                using (var context = new ImplicitConfigButNoServicesBlogContext(serviceProvider))
                {
                    context.Blogs.Add(new Blog {
                        Name = "The Waffle Cart"
                    });
                    context.SaveChanges();
                }
            }).Message);
        }
        public void Throws_on_attempt_to_use_store_with_no_store_services()
        {
            var serviceCollection = new ServiceCollection();
            serviceCollection.AddEntityFramework();
            var serviceProvider = serviceCollection.BuildServiceProvider();

            Assert.Equal(
                CoreStrings.NoProviderServices,
                Assert.Throws<InvalidOperationException>(() =>
                    {
                        using (var context = new ImplicitConfigButNoServicesBlogContext(serviceProvider))
                        {
                            context.Blogs.Add(new Blog { Name = "The Waffle Cart" });
                            context.SaveChanges();
                        }
                    }).Message);
        }