LSTANCZYK
10/17/2014 - 2:54 PM

JiraClientTest.Program.cs

using System;
using System.Linq;
using TechTalk.JiraRestClient;

namespace JiraClientTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var clientX = new JiraClient<MyIssueFields>("http://localhost:8080/", "admin", "test");
            var issueX = clientX.CreateIssue("TEST", "Story", "sub");
            issueX.fields = new MyIssueFields { labels = { "lbl1", "lbl2" }, timetracking = new Timetracking { originalEstimateDays = 2.8m }, description = "detailed description", summary = "summary", customfield_10010 = "custom" };
            issueX = clientX.UpdateIssue(issueX);

            var client = new JiraClient("http://localhost:8080", "test", "test");
            var issue = client.LoadIssue(issueX);

            var link1 = client.CreateRemoteLink(issueX, new RemoteLink { title = "SpecLog", summary = "link", url = "http://speclog.net/" });
            var link2 = client.CreateRemoteLink(issue, new RemoteLink { title = "SpecRun", summary = "link", url = "http://specrun.net/" });

            link1.summary = "speclog link";
            client.UpdateRemoteLink(issue, link1);

            foreach (var link in client.GetRemoteLinks(issue))
                Console.WriteLine("link: {0} ({1}): {2}", link.title, link.summary, link.url);

            client.DeleteRemoteLink(issueX, link2);

            foreach (var comment in clientX.GetComments(issue))
                Console.WriteLine("cmmt: {0}", comment.body);

            var close = clientX.GetTransitions(issue).Single(t => t.name.Contains("Close"));
            close.fields = new { resolution = new { name = "Won't Fix" } };
            client.TransitionIssue(issueX, close);

            clientX.DeleteIssue(issue);
        }
    }

    class MyIssueFields : IssueFields
    {
        public string customfield_10010 { get; set; }
    }
}