public void ShouldPostToBasecampUrl()
        {
            var settings = new BaseCampSettings
                {
                    CategoryId = "cat",
                    MainUrl = _server.RootUrl.TrimEnd('/'),
                    UserId = "usr",
                    Password = "******",
                    ProjectId = "proj"
                };
            var message = new BaseCampMessage
                {
                    Body = "message",
                    CategoryId = settings.CategoryId,
                    Title = "hi"
                };

            string body = null;
            string contentType = null;

            //TODO: the Juicy web server doesn't support the post bdy yet
            // (it's broken) so we will ignore that for now.

            _server.Mount(settings.NewPostPath, (req, resp) =>
                {
                    //body = req.PostBody;
                    contentType = req["Content-Type"];
                });

            UnfuddleChangesetHandler.PostNewMessageToBasecamp(message, settings);
            //Assert.AreEqual(message.ToXml(settings), body);
            Assert.AreEqual("application/xml", contentType);
        }
 public static BaseCampMessage CreateBasecampMessage(Changeset changeset, BaseCampSettings settings)
 {
     /*
     POST /projects/#{project_id}/posts.xml
         <request>
           <post>
             <category-id>#{category_id}</category-id>
             <title>#{title}</title>
             <body>#{body}</body>
             <extended-body>#{extended_body}</extended-body>
             <private>1</private> <!-- only for firm employees -->
           </post>
           <notify>#{person_id}</notify>
           <notify>#{person_id}</notify>
         </request>
      */
     return new BaseCampMessage
         {
             Title = string.Format("{0} committed revision {1} in {2}",
                                   changeset.Author,
                                   changeset.Revision,
                                   changeset.Repository),
             Body = changeset.Message,
             CategoryId = settings.CategoryId
         };
 }
        public string ToXml(BaseCampSettings settings)
        {
            var msg = new XmlDocument();
            msg.LoadXml(
                @"<request>
                  <post>
                    <category-id></category-id>
                    <title></title>
                    <body></body>
                  </post>
                </request>"
                );

            msg.SelectSingleNode("request/post/category-id").InnerText = settings.CategoryId;
            msg.SelectSingleNode("request/post/title").InnerText = Title;
            msg.SelectSingleNode("request/post/body").InnerText = Body;

            return msg.OuterXml;
        }
        public static void PostNewMessageToBasecamp(BaseCampMessage message, BaseCampSettings settings)
        {
            string url = settings.NewPostUrl;

            var messageXml = message.ToXml(settings);
            GetResponseBodyFromUrlViaPost(url, messageXml, "application/xml");
        }