public void ShouldGetAllCommentsOfPhoto() { //arrange var user = GenerateUser(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); var comment = GenerateComment(user.Id, photo.Id); dataLayer.AddComment(comment); var anotherComment = GenerateComment(user.Id, photo.Id); dataLayer.AddComment(anotherComment); photo.AllComments = dataLayer.GetAllComments(photo.Id); foreach (var currentComment in photo.AllComments) { Assert.AreEqual(currentComment.PhotoId, photo.Id); } //assert }
public void ShouldAddGetDeleteComment() { //arrange var comment = new Comment { UserId = Guid.Parse("3c8fddae-8ebc-4cd4-9eb2-30ce678d6c23") /*Guid.NewGuid()*/, PostId = Guid.Parse("82243a65-d1e6-440c-a906-5dffb9cd653c") /*Guid.NewGuid()*/, Date = DateTime.Now, CommentText = "This is my comment"/*Guid.NewGuid().ToString()*/ }; //act var dataLayer = new DataLayer.Sql.DataLayer(_connectionString); var addComment = dataLayer.AddComment(comment); var dataLayer1 = new DataLayer.Sql.DataLayer(_connectionString); var getComment = dataLayer1.GetComment(addComment.CommentId); var dataLayer2 = new DataLayer.Sql.DataLayer(_connectionString); int isDeleted = dataLayer2.DeleteComment(getComment.CommentId); //asserts Assert.AreEqual(addComment.CommentId, getComment.CommentId); Assert.AreEqual(addComment.UserId, getComment.UserId); Assert.AreEqual(addComment.PostId, getComment.PostId); //Assert.AreEqual(addComment.Date, getComment.Date); Assert.AreEqual(addComment.CommentText, getComment.CommentText); Assert.IsNotNull(isDeleted); }
public void ShouldDeleteHashtag() { //arrange var user = GenerateUser(); var hashtag = Guid.NewGuid().ToString(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); var comment = GenerateComment(user.Id, photo.Id); dataLayer.AddComment(comment); comment = dataLayer.AddHashtag(comment, hashtag); dataLayer.DeleteHashtag(comment, hashtag); var haveHashtag = dataLayer.HaveHashtag(comment, hashtag); //assert Assert.AreEqual(haveHashtag, false); }
public void ShouldUpdateComment() { //arrange var user = GenerateUser(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); var comment = GenerateComment(user.Id, photo.Id); dataLayer.AddComment(comment); var commentUpdate = GenerateComment(user.Id, photo.Id); dataLayer.UpdateComment(comment.Id, commentUpdate); commentUpdate = dataLayer.GetComment(comment.Id); var resComment = dataLayer.GetComment(comment.Id); //assert Assert.AreEqual(resComment.Id, commentUpdate.Id); }
public void ShouldAddComment() { //arrange var user = GenerateUser(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); var comment = GenerateComment(user.Id, Guid.NewGuid()); dataLayer.AddComment(comment); var resultComment = dataLayer.GetComment(comment.Id); //assert Assert.AreNotEqual(resultComment.Id, Guid.Empty); }