Created
March 16, 2012 21:39
-
-
Save KevM/2052900 to your computer and use it in GitHub Desktop.
CSharp test fixture that creates a case using a webservice based on the Dovetail SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Specialized; | |
using System.Net; | |
using System.Web.Script.Serialization; | |
using NUnit.Framework; | |
namespace Micros.Clarify.Webservices.Tests | |
{ | |
public class CreateCaseResult | |
{ | |
public string Id { get; set; } | |
} | |
[TestFixture] | |
public class micros_web_service_example | |
{ | |
[Test] | |
public void create_case_api_example() | |
{ | |
//api url | |
const string createCaseUrl = "http://localhost:39656/api/cases/create/"; | |
//particular to the submitting site | |
const string authToken = "7B118ABB-43C0-4215-A1D4-D536843728B5"; | |
const string propertyCode = "0595"; | |
const string summary = "This is the case title"; | |
const string notes = "These are case notes."; | |
const string alternateCaseId = "12345"; | |
var postData = new NameValueCollection | |
{ | |
{"authToken", authToken}, | |
{"propertyCode", propertyCode}, | |
{"summary", summary}, | |
{"notes", notes}, | |
{"AlternateCaseID", alternateCaseId} | |
}; | |
var webClient = new WebClient(); | |
webClient.Headers.Add("Accept", "application/json"); | |
var response = webClient.UploadValues(createCaseUrl, postData); | |
var json = System.Text.Encoding.UTF8.GetString(response); | |
Console.WriteLine("json returned is: {0} ", json); | |
var result = new JavaScriptSerializer().Deserialize<CreateCaseResult>(json); | |
Assert.IsNotNullOrEmpty(result.Id); | |
Console.WriteLine("Case {0} was created.", result.Id); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment