コード例 #1
0
        static void RunPatternBasedOnSelectedOption(string option)
        {
            switch (option)
            {
            case "1":
                ExecutionBuilderPattern.Run();
                break;

            case "2":
                ExecutionAbstractFactory.Run();
                break;

            case "3":
                ExecutionFactoryMethod.Run();
                break;

            case "4":
                ExecutionSingleton.Run();
                break;

            case "5":
                ExecutionAdapter.Run();
                break;

            case "6":
                ExecutionFacade.Run();
                break;

            case "7":
                ExecutionComposite.Run();
                break;

            case "8":
                ExecutionDecorator.Run();
                break;

            case "9":
                ExecutionCommand.Run();
                break;

            case "10":
                ExecutionStrategy.Run();
                break;

            case "11":
                ExecutionObserver.Run();
                break;

            case "12":
                ExecutionMediator.Run();
                break;

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #2
0
        public virtual void setup()
        {
            channel = new Mock <INetworkChannel>();

            channel.Setup(ch => ch.Send(It.IsAny <string>())).Callback((string message) =>
            {
                sentMessages.Add(message);
            });

            sentMessages = new List <string>();

            var channelFactory = new Mock <IChannelFactory>();

            channelFactory.Setup(f => f.Create()).Returns(channel.Object);

            adapter = new ExecutionAdapter(channelFactory.Object);
        }
コード例 #3
0
        public ITestRunner Create(LaunchOptions options)
        {
            string testAssemblyPath = options.DotNet.Project;

            if (testAssemblyPath == null)
            {
                throw new DotNetTestNSpecException("Command line arguments must include path of test project assembly");
            }

            var controllerProxy = proxyFactory.Create(testAssemblyPath);

            if (!options.DotNet.Port.HasValue)
            {
                return(new ConsoleRunner(testAssemblyPath, controllerProxy, options.NSpec));
            }

            ITestRunner runner;

            if (options.DotNet.List)
            {
                var adapter = new DiscoveryAdapter(channelFactory);

                runner = new DiscoveryRunner(testAssemblyPath, controllerProxy, adapter);
            }
            else if (options.DotNet.WaitCommand)
            {
                var adapter = new ExecutionAdapter(channelFactory);

                runner = new ExecutionRunner(testAssemblyPath, controllerProxy, adapter);
            }
            else
            {
                throw new DotNetTestNSpecException("Design-time command line argument must include either list or wait command options");
            }

            return(runner);
        }
コード例 #4
0
        static void Main()
        {
            Console.WriteLine("Escolha a operação:");
            Console.WriteLine("------------------------");
            Console.WriteLine("Creational Patterns");
            Console.WriteLine("------------------------");
            Console.WriteLine("1 - Abstract Factory");
            Console.WriteLine("2 - Method Factory");
            Console.WriteLine("3 - Singleton");
            Console.WriteLine("------------------------");
            Console.WriteLine("Structural Patterns");
            Console.WriteLine("------------------------");
            Console.WriteLine("4 - Adapter");
            Console.WriteLine("5 - Facade");
            Console.WriteLine("6 - Composite");
            Console.WriteLine("------------------------");
            Console.WriteLine("Behavioral Patterns");
            Console.WriteLine("------------------------");
            Console.WriteLine("7 - Command");
            Console.WriteLine("8 - Strategy");
            Console.WriteLine("9 - Observer");
            Console.WriteLine("------------------------");

            var option = Console.ReadKey();

            Console.WriteLine("");
            Console.WriteLine("------------------------");
            Console.WriteLine("");

            switch (option.KeyChar)
            {
            case '1':
                ExecutionAbstractFactory.Run();
                break;

            case '2':
                ExecutionFactoryMethod.Run();
                break;

            case '3':
                ExecutionSingleton.Run();
                break;

            case '4':
                ExecutionAdapter.Run();
                break;

            case '5':
                ExecutionFacade.Run();
                break;

            case '6':
                ExecutionCompoiste.Run();
                break;

            case '7':
                ExecutionCommand.Run();
                break;

            default:
                break;
            }

            Console.ReadKey();
            Console.Clear();
            Main();
        }