I've got a asp.net core 2.0 project I'm building in Visual Studio 2017. I'm learning the ropes with testing a asp.net core project but I'm wondering how to test the HHTPGET methods within my controller.
Below is my initial controller.
public class ValuesController : Controller
{
private Config MyConfig { get; }
private Solr Solr { get; }
private Voyager Voyager { get; }
private Messages Messages { get; }
public ValuesController(Config config, Solr solr, Voyager voyager, Messages messages)
{
MyConfig = config;
Solr = solr;
Voyager = voyager;
Messages = messages;
}
// GET api/values
[HttpGet]
[Route("/api/[Controller]")]
public IEnumerable<string> Get()
{
string version = ".NET Framework: " + Environment.Version.ToString();
string vers = "ASP.NET Core Framework: " + typeof(Controller).Assembly.GetName().Version.ToString();
return new string[] { version, vers };
}
[HttpGet]
[Route("/api/[Controller]/config")]
public JsonResult GetConfig()
{
return new JsonResult(MyConfig);
}
[HttpGet]
[Route("/api/[Controller]/solr")]
public JsonResult GetSolr()
{
return new JsonResult(Solr);
}
[HttpGet]
[Route("/api/[Controller]/voyager")]
public JsonResult GetVoyager()
{
return new JsonResult(Voyager);
}
[HttpGet]
[Route("/api/[Controller]/messages")]
public JsonResult GetMessages()
{
return new JsonResult(Messages);
}
Just wondering if someone could give an example of how to test these routes or HTTPGets...