Example #1
0
        static void Main(string[] args)
        {
            string str = @"Hello World!";

            IStrategyInterface strategy = WriterFactory.CreateWriter("CONSOLE");

            strategy.Write(str);
        }
Example #2
0
        public async Task TestOutput()
        {
            using (RedirectConsole console = new RedirectConsole())
            {
                IStrategyInterface strategy = WriterFactory.CreateWriter("CONSOLE");
                strategy.Write(@"Hello World!");

                Assert.IsTrue(console.ToString().Contains("Hello World!"));
            }
        }
Example #3
0
        public static IStrategyInterface CreateWriter(string type)
        {
            IStrategyInterface strategy = (IStrategyInterface)objectFactory.GetTypeInstance(type);

            return(strategy != null ? strategy : new WriteToConsoleStrategy());
        }