public void Test_HelloWorld_Service_API() { //Commented out, can use Moq framework in future for test so tests do not write to database or console text file ect. /*var repository = new Mock<IRepository>(); * repository.Setup(mock => mock.GetMessage()).Returns("Hello World!");*/ IRepository repository = new SimpleRepository(); IHelloWorldService service = new HelloWorldConsoleService(repository); Assert.Equals(service.Write(), "Successfully written"); }
static void Main(string[] args) { try { // where we read hello world string - can change this to multiple sources later IRepository repository = new SimpleRepository(); // service api we are using to write IHelloWorldService service; // read the WriteLocation from App.config to determine WriteLocation string writeLocation = ConfigurationManager.AppSettings["WriteLocation"]; // where are we writting to switch (writeLocation) { case "Console": { service = new HelloWorldConsoleService(repository); break; } default: // default to ConsoleService - TODO add other location later { service = new HelloWorldConsoleService(repository); break; } } string message = service.Write(); if (message == string.Empty) { //TODO: Error Logging } } catch (Exception) { //TODO: Error Logging } // prevent console from closing Console.Read(); }