/// <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 RosetteCategory) { RosetteCategory other = obj as RosetteCategory; List <bool> conditions = new List <bool>() { this.Confidence == other.Confidence, this.Label == other.Label }; return(conditions.All(condition => condition)); } else { return(false); } }
public void CategoriesContentTestFull() { Init(); JsonSerializer serializer = new JsonSerializer(); List<RosetteCategory> categories = new List<RosetteCategory>(); RosetteCategory cat0 = new RosetteCategory("ARTS_AND_ENTERTAINMENT", (decimal)0.23572849069656435); categories.Add(cat0); 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, object> content = new Dictionary<string, object>(); content.Add("categories", categories); Dictionary<string, string> responseHeaders = serializer.Deserialize<Dictionary<string, string>>(new JsonTextReader(new StringReader(headersAsString))); String mockedContent = "{\"categories\": [ { \"label\": \"" + cat0.Label + "\", \"confidence\": " + cat0.Confidence + "} ] }"; HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent); _mockHttp.When(_testUrl + "categories").Respond(mockedMessage); CategoriesResponse expected = new CategoriesResponse(categories, responseHeaders, null, mockedContent); CategoriesResponse response = _rosetteApi.Categories("Sony Pictures is planning to shoot a good portion of the new \"\"Ghostbusters\"\" in Boston as well."); Assert.AreEqual(expected, response); }