/// <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 InfoResponse) { InfoResponse other = obj as InfoResponse; List <bool> conditions = new List <bool>() { this.BuildNumber == other.BuildNumber, this.BuildTime == other.BuildTime, this.Version == other.Version, this.Name == other.Name, 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 InfoTestFull() { Init(); string name = "Rosette API"; string version = "1.2.3"; string buildNumber = null; string buildTime = null; 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("name", name); content.Add("version", version); content.Add("buildNumber", buildNumber); content.Add("buildTime", buildTime); Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString); HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, new JavaScriptSerializer().Serialize(content)); _mockHttp.When(_testUrl + "info").Respond(mockedMessage); InfoResponse expected = new InfoResponse(name, version, buildNumber, buildTime, responseHeaders, content); InfoResponse response = _rosetteApi.Info(); Assert.AreEqual(expected, response); }