Пример #1
0
 /// <summary>
 /// Equals override
 /// </summary>
 /// <param name="obj">The object to compare</param>
 /// <returns>True if equal</returns>
 public override bool Equals(object obj)
 {
     if (obj is TextEmbeddingResponse)
     {
         TextEmbeddingResponse other      = obj as TextEmbeddingResponse;
         List <bool>           conditions = new List <bool>()
         {
             this.TextEmbedding != null && other.TextEmbedding != null?this.TextEmbedding.SequenceEqual(other.TextEmbedding) : this.TextEmbedding == other.TextEmbedding,
                 this.ResponseHeaders != null && other.ResponseHeaders != null?this.ResponseHeaders.Equals(other.ResponseHeaders) : this.ResponseHeaders == other.ResponseHeaders
         };
         return(conditions.All(condition => condition));
     }
     else
     {
         return(false);
     }
 }
Пример #2
0
 public void TextEmbeddingTestFull()
 {
     Init();
     List<double> vector = new List<double>() {0.02164695, 0.0032850206, 0.0038508752, -0.009704393, -0.0016203842};
     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("embedding", vector);
     TextEmbeddingResponse expected = new TextEmbeddingResponse(vector, responseHeaders, content, null);
     String mockedContent = expected.ContentToString();
     HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
     _mockHttp.When(_testUrl + "text-embedding").Respond(mockedMessage);
     TextEmbeddingResponse response = _rosetteApi.TextEmbedding("The Ghostbusters movie was filmed in Boston.");
     Assert.AreEqual(expected, response);
 }