Пример #1
0
        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);
        }
Пример #2
0
        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
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }