Пример #1
0
        public void Post_props_are_set_on_create_test()
        {
            var image = new Images
            {
                Id = 1,
                ImageName = "TestImage",
                ImagePath = "Image",
                ImageUrl = "Image"
            };

            var post = new Posts
            {
                Id = 5,
                Content = "Det her er en test",
                Header = "Test",
                Subject = "Testing",
                Summary = "Testet",
                Images = image
            };

            Assert.AreEqual(post.Id, 5);
            Assert.AreEqual(post.Content, "Det her er en test");
            Assert.AreEqual(post.Header, "Test");
            Assert.AreEqual(post.Subject, "Testing");
            Assert.AreEqual(post.Summary, "Testet");
            Assert.AreEqual(post.Images.Id, 1);
            Assert.AreEqual(post.Images.ImageName, "TestImage");
            Assert.AreEqual(post.Images.ImagePath, "Image");
            Assert.AreEqual(post.Images.ImageUrl, "Image");
        }
        public void Post_is_updated_after_update()
        {
            var image = new Images
            {
                Id = -1,
                ImageName = "TestImage",
                ImagePath = "Image",
                ImageUrl = "Image"
            };
            facade.GetImageRepository().Add(image);
            var post1 = new Posts() {
                Id = 1,Summary = "Test",
                Subject = "Tests",
                Header = "Still a Test",
                Content = "This is a very good test thing...",
                Images = image
            };
            facade.GetPostRepository().Add(post1);
            Assert.IsNotNull(post1);

            var newheader = "shaun";
            post1.Header = newheader;

            facade.GetPostRepository().Update(post1);
            Assert.AreEqual(newheader, post1.Header);
        }
        // PUT api/values/5
        public Posts PutPost(int id, Posts post)
        {
            if (post == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            post.Id = id;

            new Facade().GetPostRepository().Update(post);
            return post;
        }
 public void Post_is_in_db_after_add()
 {
     var image = new Images
     {
         Id = -1,
         ImageName = "TestImage",
         ImagePath = "Image",
         ImageUrl = "Image"
     };
     facade.GetImageRepository().Add(image);
     var post = new Posts
     {
         Id = -1,
         Header = "Test",
         Content = "TestyTestTest",
         Subject = "This is a Test",
         Summary = "Still a test",
         Images = image
     };
     facade.GetPostRepository().Add(post);
     Assert.IsTrue(post.Id > 0);
     var post2 = facade.GetPostRepository().Read(post.Id);
     Assert.AreEqual(post, post2);
 }
 // POST api/values
 public Posts PostPost(Posts post)
 {
     return new Facade().GetPostRepository().Add(post);
 }