Esempio n. 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 SentenceTaggingResponse)
     {
         SentenceTaggingResponse other      = obj as SentenceTaggingResponse;
         List <bool>             conditions = new List <bool>()
         {
             this.Sentences != null && other.Sentences != null?this.Sentences.SequenceEqual(other.Sentences) : this.Sentences == other.Sentences,
                 this.ResponseHeaders != null && other.ResponseHeaders != null?this.ResponseHeaders.Equals(other.ResponseHeaders) : this.ResponseHeaders == other.ResponseHeaders,
                     this.GetHashCode() == other.GetHashCode()
         };
         return(conditions.All(condition => condition));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
 public void SentencesTestFull()
 {
     Init();
     string s0 = "This land is your land. ";
     string s1 = "This land is my land\nFrom California to the New York island;\nFrom the red wood forest to the Gulf Stream waters\n\nThis land was made for you and Me.\n\n";
     string s2 = "As I was walking that ribbon of highway,\nI saw above me that endless skyway:\nI saw below me that golden valley:\nThis land was made for you and me.";
     List<string> sentences = new List<string>() { s0, s1, s2 };
     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("sentences", sentences);
     SentenceTaggingResponse expected = new SentenceTaggingResponse(sentences, responseHeaders, content, null);
     String mockedContent = expected.ContentToString();
     HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
     _mockHttp.When(_testUrl + "sentences").Respond(mockedMessage);
     SentenceTaggingResponse response = _rosetteApi.Sentences("This land is your land. This land is my land\\nFrom California to the New York island;\\nFrom the red wood forest to the Gulf Stream waters\\n\\nThis land was made for you and Me.\\n\\nAs I was walking that ribbon of highway,\\nI saw above me that endless skyway:\\nI saw below me that golden valley:\\nThis land was made for you and me.");
     Assert.AreEqual(expected, response);
 }