Exemplo n.º 1
0
        public void CanAddNewBlogItemIncludingImage()
        {
            // Arrange
              Request blogRequest = Session.Bind(BlogRootPath);

              // Act ...

              // - GET blog
              Resources.Blog blog = blogRequest.Get<Resources.Blog>().Body;

              // - Follow "edit" link and GET form describing how to input
              Response<Resources.CreatePostDescriptor> createDescriptor
            = blog.Links.Select("edit").Follow(Session).Get<Resources.CreatePostDescriptor>();

              // - Extract "create" form
              IKeyValueForm form = createDescriptor.Body.Form;

              // - Populate form inputs
              Resources.CreatePostArgs args = new Resources.CreatePostArgs
              {
            Title = "New item",
            Text = "Yaj!",
            Image = new File("..\\..\\data1.gif", "image/gif")
              };
              form.Value(args);

              // - Submit the form
              Resources.Post createdPost = form.Bind().Submit<Resources.Post>().Created();

              // Assert ...
              Assert.IsNotNull(createdPost);
              Assert.AreEqual("New item", createdPost.Title);
              Assert.AreEqual("Yaj!", createdPost.Text);
        }
Exemplo n.º 2
0
        public void CanAddNewBlogItemIncludingImage()
        {
            // Arrange
            Request blogRequest = Session.Bind(BlogRootPath);

            // Act ...

            // - GET blog
            Resources.Blog blog = blogRequest.Get <Resources.Blog>().Body;

            // - Follow "edit" link and GET form describing how to input
            Response <Resources.CreatePostDescriptor> createDescriptor
                = blog.Links.Select("edit").Follow(Session).Get <Resources.CreatePostDescriptor>();

            // - Extract "create" form
            IKeyValueForm form = createDescriptor.Body.Form;

            // - Populate form inputs
            Resources.CreatePostArgs args = new Resources.CreatePostArgs
            {
                Title = "New item",
                Text  = "Yaj!",
                Image = new File("..\\..\\data1.gif", "image/gif")
            };
            form.Value(args);

            // - Submit the form
            Resources.Post createdPost = form.Bind().Submit <Resources.Post>().Created();

            // Assert ...
            Assert.IsNotNull(createdPost);
            Assert.AreEqual("New item", createdPost.Title);
            Assert.AreEqual("Yaj!", createdPost.Text);
        }