Пример #1
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);
        }
Пример #2
0
        [TestMethod]//ok
        public void GetLikeTest()
        {
            //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);
            Assert.AreEqual(dataLayer.IsLiked(post.PostId, user.UserId), true);
        }
Пример #3
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);
        }
        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);
        }