示例#1
0
 /// <summary>
 /// Equals override
 /// </summary>
 /// <param name="obj">The object to compare against</param>
 /// <returns>True if equal</returns>
 public override bool Equals(Object obj)
 {
     if (obj is LanguageIdentificationResponse)
     {
         LanguageIdentificationResponse other = obj as LanguageIdentificationResponse;
         List <bool> conditions = new List <bool>()
         {
             this.LanguageDetections != null && other.LanguageDetections != null?this.LanguageDetections.SequenceEqual(other.LanguageDetections) : this.LanguageDetections == other.LanguageDetections,
                 this.ResponseHeaders != null && other.ResponseHeaders != null?this.ResponseHeaders.Equals(other.ResponseHeaders) : this.ResponseHeaders == other.ResponseHeaders
         };
         return(conditions.All(condition => condition));
     }
     else
     {
         return(false);
     }
 }
 public void LanguageTestFull()
 {
     Init();
     LanguageDetection lang0 = new LanguageDetection("spa", (decimal)0.38719602327387076);
     LanguageDetection lang1 = new LanguageDetection("eng", (decimal)0.32699986625091865);
     LanguageDetection lang2 = new LanguageDetection("por", (decimal)0.05569054210624943);
     LanguageDetection lang3 = new LanguageDetection("deu", (decimal)0.030069489878380328);
     LanguageDetection lang4 = new LanguageDetection("zho", (decimal)0.23572849069656435);
     LanguageDetection lang5 = new LanguageDetection("swe", (decimal)0.027734757034048835);
     LanguageDetection lang6 = new LanguageDetection("ces", (decimal)0.02583105013400886);
     LanguageDetection lang7 = new LanguageDetection("fin", (decimal)0.23572849069656435);
     LanguageDetection lang8 = new LanguageDetection("fra", (decimal)0.023298946617300347);
     List<LanguageDetection> languageDetections = new List<LanguageDetection>() { lang0, lang1, lang2, lang3, lang4, lang5, lang6, lang7, lang8 };
     string headersAsString = " { \"Content-Type\": \"application/json\", \"date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"server\": \"openresty\", \"strict-transport-security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"content-length\": \"72\", \"connection\": \"Close\" }";
     Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
     Dictionary<string, object> content = new Dictionary<string, object>();
     content.Add("languageDetections", languageDetections);
     LanguageIdentificationResponse expected = new LanguageIdentificationResponse(languageDetections, responseHeaders, content, null);
     String mockedContent = expected.ContentToString();
     HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
     _mockHttp.When(_testUrl + "language").Respond(mockedMessage);
     LanguageIdentificationResponse response = _rosetteApi.Language("Por favor Señorita, says the man.");
     Assert.AreEqual(expected, response);
 }