Example #1
0
        [TestMethod]//ok
        public void DeletePostTest()
        {
            //firstly, add user to add him post
            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 resultPost = dataLayer.GetPost(post.PostId);

            dataLayer.DeletePost(post.PostId);
            var delpost = dataLayer.GetPost(post.PostId);

            Assert.AreNotEqual(delpost.PostId, resultPost.PostId);
        }
Example #2
0
        [TestMethod]//ok
        public void DeleteComTest()
        {
            //firstly, add user to add him post
            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);
            //add com to post
            var com = new Comments()
            {
                Date   = DateTime.Now,
                FromId = user.UserId,
                PostId = post.PostId,
                Text   = Guid.NewGuid().ToString().Substring(10)
            };

            dataLayer.AddCommentToPost(post.PostId, com);
            dataLayer.DeleteComment(com.ComId);
            Assert.AreEqual(dataLayer.IsComment(com.ComId), false);
        }
Example #3
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);
        }
Example #4
0
        [TestMethod]//ok
        public void GetPostTest()
        {
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);
            var user      = new Users
            {
                UserId   = Guid.NewGuid(),
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            var post = new Posts
            {
                UserId = user.UserId,
                Date   = DateTime.Now,
                Photo  = Guid.NewGuid().ToString().Substring(10)
            };

            //act
            user = dataLayer.AddUser(user);
            post = dataLayer.AddPost(post);
            //asserts
            var resultPost = dataLayer.GetPost(post.PostId);

            Assert.AreEqual(post.Photo, resultPost.Photo);
        }
        public void ShouldAddPost()
        {
            //arrange
            var post = new Post
            {
                UserId = Guid.NewGuid(),
            };
            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            post = dataLayer.AddPost(post);
            //asserts
            var resultPost = dataLayer.GetPost(post.Id);

            Assert.AreEqual(post.UserId, resultPost.UserId);
        }
        public void ShouldAddGetDeletePost()
        {
            //arrange
            var post = new Post
            {
                UserId  = Guid.Parse("3c8fddae-8ebc-4cd4-9eb2-30ce678d6c23") /*Guid.NewGuid()*/,
                Picture = Guid.NewGuid().ToByteArray(),
                Date    = DateTime.Now
            };
            //act
            var dataLayer  = new DataLayer.Sql.DataLayer(_connectionString);
            var addPost    = dataLayer.AddPost(post);
            var dataLayer1 = new DataLayer.Sql.DataLayer(_connectionString);
            var getPost    = dataLayer1.GetPost(addPost.PostId);
            var dataLayer2 = new DataLayer.Sql.DataLayer(_connectionString);
            var isDeleted  = dataLayer2.DeletePost(getPost.PostId);

            //asserts
            Assert.AreEqual(addPost.PostId, getPost.PostId);
            Assert.AreEqual(addPost.UserId, getPost.UserId);
            //Assert.AreEqual(addPost.Picture, getPost.Picture);
            //Assert.AreEqual(addPost.Date, getPost.Date);
            Assert.IsNotNull(isDeleted);
        }