/// <summary> /// /// </summary> /// <param name="element"></param> /// <param name="client"></param> public ProjectNotification(XElement element, ContentAPI client) : this() { if (element != null) { this.ProjectID = element.GetChildValueAsInt32("ProjectID"); this.Status = element.GetChildValue("Status"); this.URL = new Uri(element.GetChildValue("URL")); this.CreationDate = element.GetChildValueAsDateTime("CreationDate"); this.DueDate = element.GetChildValueAsDateTime("DueDate"); this.CompletionDate = element.GetChildValueAsDateTime("CompletionDate"); XElement errors = element.Element("Errors"); if (errors != null) { foreach (XElement error in errors.Elements("Error")) { this.ErrorsList.Add(error.Value); } } XElement sourceLanguage = element.Element("SourceLanguage"); if (sourceLanguage != null) { this.SourceLanguage = sourceLanguage.GetChildValue("LanguageCode"); } XElement targetLanguages = element.Element("TargetLanguages"); if (targetLanguages != null) { foreach (XElement targetLanguage in targetLanguages.Descendants("LanguageCode")) { this.TargetLanguagesList.Add(targetLanguage.Value); } } XElement products = element.Element("Products"); if (products != null) { this.Products = Product.CreateEnumerable(products, client); } XElement files = element.Element("Files"); if (files != null) { this.Files = File.CreateEnumerable(files, client); } } }
public void AuthorizationTest() { ContentAPI client = new ContentAPI(keyId: "aZqpaIZkYRfPFrtUWiyq", secretKey: "", endpoint: new Uri("https://developer-sandbox.liondemand.com")); try { XDocument terms = client.GetTermsAndConditions(); Assert.Fail("A request without a secret key should not be sucessful."); } catch (OnDemandClientException odce) { Assert.AreEqual<HttpStatusCode>(HttpStatusCode.Unauthorized, odce.HttpStatusCode); Assert.AreEqual<Int32>(0, odce.ReasonCode); Assert.IsNotNull(odce.SimpleMessage); Assert.IsNotNull(odce.DetailedMessage); throw; } }
/// <summary> /// /// </summary> /// <returns></returns> private void CleanupQuoteSetup(ContentAPI client, Quote quote) { // Never fail (future implementation of ListQuotes will help this) try { RejectQuoteStatus result = client.RejectQuote(quote.QuoteID); // Unit test breakpoint line if (result == RejectQuoteStatus.Success) { result = RejectQuoteStatus.Success; } } catch { } }