Exemplo n.º 1
0
 public static ICollection<Post> ListWithMultiplePostsAndOneSubBranch(Topic topic, Post parent)
 {
     return new List<Post>
                {
                    PostWithOneChild(1234, topic, parent),
                    PostWithOneChild(2345, topic, parent),
                    PostWithOneChild(3456, topic, parent),
                };
 }
Exemplo n.º 2
0
 public static ICollection<Post> ListWithMultiplePostsAndNoSubBranches(Topic topic, Post parent)
 {
     return new List<Post>
                {
                    PostWithNoChildren(1234, topic, parent),
                    PostWithNoChildren(2345, topic, parent),
                    PostWithNoChildren(3456, topic, parent)
                };
 }
Exemplo n.º 3
0
 public static Post PostWithMultipleChildrenAsLeaves(int id, Topic topic, Post parent)
 {
     var data = MakeBase(id, topic, parent, new DateTime(2010, 2, 2));
     data.Children = new List<Post>
                         {
                             PostWithNoChildren(4567, topic, parent),
                             PostWithNoChildren(5678, topic, parent),
                             PostWithNoChildren(6789, topic, parent)
                         };
     return data;
 }
Exemplo n.º 4
0
 public static Post MakeBase(int id, Topic topic, Post parent, DateTime date)
 {
     return new Post
                {
                    Id = id,
                    Topic = topic,
                    TopicId = topic.Id,
                    Parent = parent,
                    ParentId = (parent == null ? default(int?) : parent.Id),
                    Body = MakeBody(id),
                    Author = MakeAuthor(id),
                    PublishedDate = date
                };
 }
Exemplo n.º 5
0
 public static ICollection<Post> ListWithMultiplePostsAndMultipleSubBranchesAsLeaves(Topic topic, Post parent)
 {
     return new List<Post>
                {
                    PostWithMultipleChildrenAsLeaves(1234, topic, parent),
                    PostWithMultipleChildrenAsLeaves(2345, topic, parent),
                    PostWithMultipleChildrenAsLeaves(3456, topic, parent)
                };
 }
Exemplo n.º 6
0
 public static ICollection<Post> ListWithOnePostAndNoSubBranches(Topic topic, Post parent)
 {
     return new List<Post> {PostWithNoChildren(1234, topic, parent)};
 }
Exemplo n.º 7
0
 public static Post PostWithOneChild(int id, Topic topic, Post parent)
 {
     var data = MakeBase(id, topic, parent, new DateTime(2010, 2, 2));
     data.Children = ListWithOnePostAndNoSubBranches(topic, parent);
     return data;
 }
Exemplo n.º 8
0
 public static Post PostWithNoChildren(int id, Topic topic, Post parent)
 {
     var data = MakeBase(id, topic, parent, new DateTime(2010, 1, 1));
     data.Children = ListWithNoPosts();
     return data;
 }
Exemplo n.º 9
0
     private void FixupParent(Post previousValue)
     {
         if (previousValue != null && previousValue.Children.Contains(this))
         {
             previousValue.Children.Remove(this);
         }
 
         if (Parent != null)
         {
             if (!Parent.Children.Contains(this))
             {
                 Parent.Children.Add(this);
             }
             if (ParentId != Parent.Id)
             {
                 ParentId = Parent.Id;
             }
         }
         else if (!_settingFK)
         {
             ParentId = null;
         }
     }