public void Find_with_some_matched()
 {
     using (var context = new BloggingContext(_serviceProvider, _contextOptions))
     {
         var service = new BlogService(context);
         var result = service.Find("cat");
         Assert.AreEqual(2, result.Count());
     }
 }
 public void Find_with_unmatched_term()
 {
     using (var context = new BloggingContext(_serviceProvider, _contextOptions))
     {
         var service = new BlogService(context);
         var result = service.Find("horse");
         Assert.AreEqual(0, result.Count());
     }
 }
        public void Find_searches_url()
        {
            // All contexts that share the same service provider will share the same InMemory database
            var options = CreateNewContextOptions();

            // Insert seed data into the database using one instance of the context
            using (var context = new BloggingContext(options))
            {
                context.Blogs.Add(new Blog { Url = "http://sample.com/cats" });
                context.Blogs.Add(new Blog { Url = "http://sample.com/catfish" });
                context.Blogs.Add(new Blog { Url = "http://sample.com/dogs" });
                context.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var context = new BloggingContext(options))
            {
                var service = new BlogService(context);
                var result = service.Find("cat");
                Assert.AreEqual(2, result.Count());
            }
        }
        public void Find_searches_url()
        {
            // All contexts created from this service provider will access the same InMemory database
            var serviceProvider = _serviceCollection.BuildServiceProvider();

            // Insert seed data into the database using one instance of the context
            using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
            {
                var context = scope.ServiceProvider.GetService<BloggingContext>();
                context.Blogs.Add(new Blog { Url = "http://sample.com/cats" });
                context.Blogs.Add(new Blog { Url = "http://sample.com/catfish" });
                context.Blogs.Add(new Blog { Url = "http://sample.com/dogs" });
                context.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
            {
                var context = scope.ServiceProvider.GetService<BloggingContext>();
                var service = new BlogService(context);
                var result = service.Find("cat");
                Assert.AreEqual(2, result.Count());
            }
        }