public HttpResponseMessage CompareString([FromBody] CompareRequest request) { try { Log.Info("initialiing compare"); var httpResponseMessage = new HttpResponseMessage() { Content = new ObjectContent <int[]>(StringCompare.Compare(request.SourceString, request.SubString).ToArray(), Configuration.Formatters.JsonFormatter), StatusCode = HttpStatusCode.OK, }; return(httpResponseMessage); } catch (Exception ex) { var errorMessage = Helper.HttpResponseErrorMessage(ex.Message, _correlationId); Log.Error(string.Format("{0} - {1}", _correlationId, "Exception occurred: Unable to determine traingle type"), ex); throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, errorMessage)); } }
public void Test_DetermineTriangleType() { Assert.AreEqual(new int[] { 6, 24 }, StringCompare.Compare("hello test user this is test", "test"), "Test Failed"); Assert.AreEqual(new List <int>().ToArray(), StringCompare.Compare("hello test user this is test", "test1"), "Test Failed"); }