static void Main(string[] args) { //creating objects for API classes to write messages on console or to the database. HelloWorldConsole hwc = new HelloWorldConsole(); hwc.SetConsoleMsg("Hellow World!"); hwc.displayConsoleMessage(); //similary we can add a code to write messages to database HelloWorldDatabase hwd = new HelloWorldDatabase(); hwd.SetConsoleMsg("Write Hellow World to database"); hwd.DBWrite(); //using configuation file to determine where to write the information switch (ConfigurationManager.AppSettings["AppType"]) { case "Console": HelloWorldConsole hwcApp = new HelloWorldConsole(); hwcApp.SetConsoleMsg("Hello World!"); hwcApp.displayConsoleMessage(); break; case "Database": HelloWorldConsole hwdApp = new HelloWorldConsole(); hwdApp.SetConsoleMsg("Hello World!"); hwdApp.DBWrite(); break; default: Console.Write("Invalid option for AppType"); break; } Console.ReadKey(); }
public void SetConsoleMessage() { HelloWorldConsole hwc = new HelloWorldConsole(); hwc.SetConsoleMsg("Hello World"); //verify if HelloWorldConsole object is not null Assert.IsNotNull(hwc); //verify if both the objects are equal Assert.AreEqual("Hello World", hwc.consoleMsg); }