Ejemplo n.º 1
0
        public void PostsByTag_Should_Return_Related_Posts()
        {
            var posts = new List<Post>();
            var tags = new List<Tag>();
            var rel = new List<Tags_Post>();

            var post = new Post();
            post.PostID = 1;
            post.Title = "Tagged Post";
            posts.Add(post);

            var tag = new Tag();
            tag.TagID = 1;
            tag.Description = "tag";
            tags.Add(tag);

            var tp = new Tags_Post();
            tp.PostID = 1;
            tp.TagID = 1;
            rel.Add(tp);

            //setup SubSonic
            Post.Setup(posts);
            Tag.Setup(tags);
            Tags_Post.Setup(rel);

            var result = Post.PostsByTags("tag");
            Assert.Equal(1,result.Count());
        }
Ejemplo n.º 2
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for(int i=0;i<testItems;i++){
         Tag item=new Tag();
         _testRepo._items.Add(item);
     }
 }
Ejemplo n.º 3
0
 public static void Setup(Tag item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Ejemplo n.º 4
0
        static void ImportTags()
        {
            Write("Deleting tags");
            //delete existing
            Tag.Delete(x => x.TagID > 0);

            //pull the WP tags
            var query = from t in wp_term.All()
                        join tt in wp_term_taxonomy.All() on t.term_id equals tt.term_id
                        where tt.taxonomy == "post_tag"
                        select t;

            foreach (var term in query){
                //add the tag to the DB
                Write("Adding tag "+term);
                var t = new Tag();
                t.Description = term.name;
                t.Slug = term.slug;
                t.Add();
            }
            Write("Finished importing tags **************************");
        }