public JsonResult GetHelloWorld() { string strReturnData = string.Empty; try { IHelloWorld oHelloWold = null; //this code can be called to return Simple hardcoded implementation of HelloWold oHelloWold = new SimpleHelloWorld(); //this code can be called to return Database implementation of HelloWold - commented as of now //oHelloWold = new DBHelloWorld(); oHelloWold.TxtData = "This is success data."; strReturnData = oHelloWold.GetText(); } catch (Exception ex) { strReturnData = "This is error data."; //TO DO - call a centrallized logger(log4net, loggly etc) to log the error } // return the JSON Data return(new JsonResult { Data = strReturnData }); }
public void ReturnHelloWorld() { string result = SimpleHelloWorld.ReturnHelloWorld(); Assert.AreEqual("Hello, world!", result); }