Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string str = @"Hello World!";

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

            strategy.Write(str);
        }
Exemplo n.º 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!"));
            }
        }
Exemplo n.º 3
0
        public static IStrategyInterface CreateWriter(string type)
        {
            IStrategyInterface strategy = (IStrategyInterface)objectFactory.GetTypeInstance(type);

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