示例#1
0
        public void TestNullReturn()
        {
            BlogPostContext    ctx     = newContext();
            BlogPostCtxWrapper wrapper = new BlogPostCtxWrapper(ctx);
            BlogController     bpc     = new BlogController(wrapper);
            var obj = bpc.Get(2);

            Assert.Null(obj.Value);
        }
示例#2
0
        public void TestSimpleReturn()
        {
            BlogPostContext    ctx     = newContext();
            BlogPostCtxWrapper wrapper = new BlogPostCtxWrapper(ctx);
            BlogController     bpc     = new BlogController(wrapper);
            var obj = bpc.Get(1);

            Assert.Equal("Help", obj.Value.Title);
            Assert.Equal(1, obj.Value.Version);
        }
示例#3
0
        public void testBlogPostCreate()
        {
            var ctx = newContext();
            BlogPostCtxWrapper wrapper = new BlogPostCtxWrapper(ctx);
            var writterpost            = wrapper.createBlogPost(new DBBlogPost()
            {
                Title = "Whatto", Date = DateTime.Now, File = "johnboy", Status = true, Version = 0
            });

            Assert.Equal(1, writterpost.Id);
        }
示例#4
0
        public void testUpdate()
        {
            var ctx     = newContext();
            var wrapper = new BlogPostCtxWrapper(ctx);
            var oldblog = wrapper.getBlogPost(1);
            // copied because oldblog is written over by the update function, unfortunately.
            var updblog = new DBBlogPost()
            {
                Id = oldblog.Id, Title = "Flimsey Fool", Date = DateTime.Now, File = oldblog.File, Status = oldblog.Status, Version = oldblog.Version
            };

            wrapper.updateBlogPost(updblog);
            var newblog = wrapper.getBlogPost(1);

            Assert.Equal(oldblog.Id, newblog.Id);
            Assert.NotEqual(oldblog.Version, newblog.Version);
        }