public void Delete_Post_with_Id_2() { var post = new Post() { Id = 2 }; var count = _repository.Posts.Count(); _repository.DeletePost(post); Assert.AreEqual(count - 1, _repository.Posts.Count()); Assert.IsNull(_repository.Posts.WithId(2)); }
public void Add_Post() { var post = new Post() {Id = 10, Title = "title10"}; var count = _repository.Posts.Count(); _repository.AddPost(post); Assert.AreEqual(count + 1, _repository.Posts.Count()); Assert.IsNotNull(_repository.Posts.WithId(10)); Assert.AreEqual(_repository.Posts.WithId(10).Title, "title10"); }
/// <summary> /// Create a new Post object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="blogId">Initial value of the BlogId property.</param> /// <param name="categoryId">Initial value of the CategoryId property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="body">Initial value of the Body property.</param> /// <param name="createdOn">Initial value of the CreatedOn property.</param> public static Post CreatePost(global::System.Int32 id, global::System.Int32 blogId, global::System.Int32 categoryId, global::System.String title, global::System.String body, global::System.DateTime createdOn) { Post post = new Post(); post.Id = id; post.BlogId = blogId; post.CategoryId = categoryId; post.Title = title; post.Body = body; post.CreatedOn = createdOn; return post; }
/// <summary> /// Deprecated Method for adding a new object to the Posts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPosts(Post post) { base.AddObject("Posts", post); }