Beispiel #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);
        }
        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);
        }