Exemplo n.º 1
0
        [TestMethod]//ok
        public void DeleteLikeTest()
        {
            //arrange
            var user = new Users
            {
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            user = dataLayer.AddUser(user);
            //add post to user
            var post = new Posts
            {
                UserId = user.UserId,
                Date   = DateTime.Now,
                Photo  = Guid.NewGuid().ToString().Substring(10)
            };

            post = dataLayer.AddPost(post);
            var like = new Likes
            {
                PostId = post.PostId,
                UserId = user.UserId
            };

            dataLayer.AddLike(like);
            dataLayer.DeleteLike(like.PostId, like.UserId);
            var check = dataLayer.IsLiked(post.PostId, user.UserId);

            Assert.AreEqual(check, false);
        }
        public void ShouldAddGetDeleteLike()
        {
            //arrange
            var like = new Like
            {
                UserId = Guid.Parse("3c8fddae-8ebc-4cd4-9eb2-30ce678d6c23") /*Guid.NewGuid()*/,
                PostId = Guid.Parse("82243a65-d1e6-440c-a906-5dffb9cd653c") /*Guid.NewGuid()*/,
            };
            //act
            var dataLayer  = new DataLayer.Sql.DataLayer(_connectionString);
            var addLike    = dataLayer.AddLike(like);
            var dataLayer1 = new DataLayer.Sql.DataLayer(_connectionString);
            var getLike    = dataLayer1.GetLike(addLike.LikeId);
            var dataLayer2 = new DataLayer.Sql.DataLayer(_connectionString);
            int isDeleted  = dataLayer2.DeleteLike(getLike.LikeId);

            //asserts
            Assert.AreEqual(addLike.LikeId, getLike.LikeId);
            Assert.AreEqual(addLike.UserId, getLike.UserId);
            Assert.AreEqual(addLike.PostId, getLike.PostId);
            Assert.IsNotNull(isDeleted);
        }
Exemplo n.º 3
0
        public void ShouldDeleteLike()
        {
            //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);
            dataLayer.DeleteLike(photo, user);

            var haveLike = dataLayer.HaveLike(photo, user);

            //assert
            Assert.AreEqual(haveLike, false);
        }