static void Main(string[] args) { try { //If the destinations were to write to a database, or an application server. // this would garner any connection strings, address of the application server etc. // since this being written to a console, we really don't need this. var section = (ConfigurationManager.GetSection("WriteDestinations/Destinations") as System.Collections.Hashtable) .Cast <System.Collections.DictionaryEntry>() .ToDictionary(n => n.Key.ToString(), n => n.Value.ToString()); string platform = "MOBILE"; string locationInformation; section.TryGetValue(platform, out locationInformation); ITextToBase textToConsole = new TextToConsole(locationInformation); textToConsole.GetTextFromSource(); textToConsole.WriteToDestination(); } catch (ArgumentNullException e) { Console.WriteLine("ERROR: string to write is NULL: " + e.Message); } catch (Exception e) { Console.WriteLine("ERROR: " + e.Message); } }
public void TestTextToConsoleGetTextFromSource() { string testingTextString = null; string platform = "CONSOLE"; TextToConsole textToConsole = new TextToConsole(platform); textToConsole.GetTextFromSource(); testingTextString = textToConsole.TextString; //If GetTextFromSource() HAS been called, parameter // should NOT be null. Assert.AreNotEqual(null, testingTextString); }
public void TestTextToConsoleTextStringProperty() { //Simple setup: string testingTextString = null; string platform = "CONSOLE"; TextToConsole textToConsole = new TextToConsole(platform); textToConsole.GetTextFromSource(); testingTextString = textToConsole.TextString; //Per specification the property should return a string type. Assert.IsInstanceOfType(testingTextString, typeof(string)); }
public void TestTextStringEqualToHelloWorld() { string Actual = null; string Expected = "Hello World!"; string platform = "CONSOLE"; TextToConsole textToConsole = new TextToConsole(platform); textToConsole.GetTextFromSource(); Actual = textToConsole.TextString; //Per the requirements the Expected value of the string should // be "Hello World!" (If its not, then requirements have changed, or // requirements are not fully understood. Assert.AreEqual(Expected, Actual); }