public void GetGoogleValueNotFound() { var config = new HttpConfiguration(); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/user/44300"); var route = config.Routes.MapHttpRoute("Default", "api/{controller}/GetGoogleValue/{id}"); var controller = new GoogleValueController { Request = request, }; controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; Assert.AreEqual(controller.GetGoogleValue("123").StatusCode, HttpStatusCode.NotFound); }
public void GetGoogleValueSuccess() { var config = new HttpConfiguration(); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/user/44300"); var route = config.Routes.MapHttpRoute("Default", "api/{controller}/GetGoogleValue/{id}"); var controller = new GoogleValueController { Request = request, }; controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; SwapDbConnection db = new SwapDbConnection(); string google_id = db.google_value.Select(x => x.google_value_id).FirstOrDefault(); Assert.AreEqual(controller.GetGoogleValue(google_id).StatusCode, HttpStatusCode.OK); }