/// <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 TranslateNamesResponse) { TranslateNamesResponse other = obj as TranslateNamesResponse; List <bool> conditions = new List <bool>() { this.ResponseHeaders != null && other.ResponseHeaders != null?this.ResponseHeaders.Equals(other.ResponseHeaders) : this.ResponseHeaders == other.ResponseHeaders, this.SourceLanguageOfOrigin != null && other.SourceLanguageOfOrigin != null?this.SourceLanguageOfOrigin.Equals(other.SourceLanguageOfOrigin) : this.SourceLanguageOfOrigin == other.SourceLanguageOfOrigin, this.SourceLanguageOfUse != null && other.SourceLanguageOfUse != null?this.SourceLanguageOfUse.Equals(other.SourceLanguageOfUse) : this.SourceLanguageOfUse == other.SourceLanguageOfUse, this.SourceScript != null && other.SourceScript != null?this.SourceScript.Equals(other.SourceScript) : this.SourceScript == other.SourceScript, this.TargetLanguage != null && other.TargetLanguage != null?this.TargetLanguage.Equals(other.TargetLanguage) : this.TargetLanguage == other.TargetLanguage, this.TargetScheme != null && other.TargetScheme != null?this.TargetScheme.Equals(other.TargetScheme) : this.TargetScheme == other.TargetScheme, this.Translation != null && other.Translation != null?this.Translation.Equals(other.Translation) : this.Translation == other.Translation, this.TargetScript != null && other.TargetScript != null?this.TargetScript.Equals(other.TargetScript) : this.TargetScript == other.TargetScript, this.EntityType != null && other.EntityType != null?this.EntityType.Equals(other.EntityType) : this.EntityType == other.EntityType, this.Confidence == other.Confidence, this.GetHashCode() == other.GetHashCode() }; return(conditions.All(condition => condition)); } else { return(false); } }
public void NameTranslationTestFull() { Init(); string translation = "Mu'ammar Muhammad Abu-Minyar al-Qadhaf"; string targetLanguage = "eng"; string targetScript = "Latn"; string targetScheme = "IC"; double confidence = (double)0.06856099342585828; 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("translation", translation); content.Add("targetLanguage", targetLanguage); content.Add("targetScript", targetScript); content.Add("targetScheme", targetScheme); content.Add("confidence", confidence); TranslateNamesResponse expected = new TranslateNamesResponse(translation, targetLanguage: targetLanguage, targetScript:targetScript, targetScheme:targetScheme, confidence: confidence, responseHeaders:responseHeaders, content: content); String mockedContent = expected.ContentToString(); HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent); _mockHttp.When(_testUrl + "name-translation").Respond(mockedMessage); Dictionary<object, object> input = new Dictionary<object, object>() { {"name", "معمر محمد أبو منيار القذاف"}, {"targetLanguage", "eng"}, {"targetScript", "Latn"} }; TranslateNamesResponse response = _rosetteApi.NameTranslation(input); Assert.AreEqual(expected, response); }