반응형
Web Project에 Controller 생성
public class SampleController : ApiController
{
[Route("GetInfos/{name?}")]
[HttpGet]
public IHttpActionResult GetInfos(string name="tester")
{
List rtn = new List();
return Ok(rtn);
}
}
Test Project
[TestMethod]
public void GetReturensInfos()
{
var controller = new SamplesMonitoring
{
Request = new HttpRequestMessage(),
Controlration = new System.Web.Http.HttpConfiguration()
};
// ACT
var respose = controller.GetInfos();
var rtn = (((System.Web.Http.Results.OkNegotiatedContentResult<System.Collection.Generic.IEnumberable<object>>)respose).Content);
StringBuilder sb = new StringBuilder();
foreach (var item in rtn)
{
sb.AppendLine(item.ToString());
}
Clipboard.SetText(sb.ToString()); // 클립 보드에 저장
Debug.WriteLine(sb.ToString());
}
반응형
'Development > ASP.NET' 카테고리의 다른 글
ASP.NET MVC Model Parameter (0) | 2015.03.27 |
---|---|
ASP.NET MVC5 Update 후 오류 (0) | 2015.02.05 |
Web.Config 를 확장해 보자 (0) | 2010.07.29 |
ASP.NET AJAX Control Toolit 빌드시 에러 (0) | 2009.03.05 |