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 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 ShouldGetLikes() { //arrange var user = GenerateUser(); var userAnother = GenerateUser(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); dataLayer.AddUser(userAnother); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); dataLayer.AddLike(photo, user); dataLayer.AddLike(photo, userAnother); photo.UsersThatLike = dataLayer.GetLikes(photo); var resAllLikes = true; foreach (var usersLikes in photo.UsersThatLike) { if (usersLikes.Id != user.Id && usersLikes.Id != userAnother.Id) { resAllLikes = false; } } //assert Assert.AreEqual(resAllLikes, true); }
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 ShouldGetPhoto() { //arrange var user = GenerateUser(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); var resPhoto = dataLayer.GetPhoto(photo.Id); //assert Assert.AreEqual(photo.Id, resPhoto.Id); }
public void ShouldAddLike() { //arrange var user = GenerateUser(); //act var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql); dataLayer.AddUser(user); var photo = GeneratePhoto(user.Id); dataLayer.AddPhoto(photo); dataLayer.AddLike(photo, user); var haveLike = dataLayer.HaveLike(photo, user); //assert Assert.AreEqual(haveLike, true); }
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); }