Example #1
0
 public void SetGenericTest()
 {
     using (var dbx = new InheritedDbContext())
     {
         Assert.IsTrue(dbx.Blogs.GetType() == dbx.Set <Blog>().GetType());
     }
 }
Example #2
0
 public void SetTest()
 {
     using (var dbx = new InheritedDbContext())
     {
         Assert.IsTrue(dbx.Blogs.GetType() == dbx.Set(typeof(Blog)).GetType());
     }
 }
        public void CreateBlog_saves_a_blog_via_InMemoryContext()
        {
            var context = new InheritedDbContext();
            var service = new BlogService(context);

            service.AddBlog("ADO.NET Blog", "http://blogs.msdn.com/adonet");

            Assert.AreEqual(1, context.Blogs.Count());
            Assert.AreEqual("ADO.NET Blog", context.Blogs.Single().Name);
            Assert.AreEqual("http://blogs.msdn.com/adonet", context.Blogs.Single().Url);
            //Assert.AreEqual(1, context.SaveChangesCount);
        }
Example #4
0
        public async Task GetAllBlogsAsync_orders_by_name_InMemoryContext()
        {
            var context = new InheritedDbContext();

            context.Blogs.Add(new Blog {
                Name = "BBB"
            });
            context.Blogs.Add(new Blog {
                Name = "ZZZ"
            });
            context.Blogs.Add(new Blog {
                Name = "AAA"
            });

            var service = new BlogService(context);
            var blogs   = await service.GetAllBlogsAsync();

            Assert.AreEqual(3, blogs.Count);
            Assert.AreEqual("AAA", blogs[0].Name);
            Assert.AreEqual("BBB", blogs[1].Name);
            Assert.AreEqual("ZZZ", blogs[2].Name);
        }