Exemplo n.º 1
0
        public void AndAClientThatConnectsToTheQueues()
        {
            var config = new ImplementationRunnerConfig()
                         .SetHostname(Hostname)
                         .SetPort(Port)
                         .SetRequestQueueName(RequestQueueName)
                         .SetResponseQueueName(ResponseQueueName)
                         .SetAuditStream(auditStream);

            queueBasedImplementationRunnerBuilder = new QueueBasedImplementationRunner.Builder().SetConfig(config);
            queueBasedImplementationRunner        = queueBasedImplementationRunnerBuilder.Create();
        }
Exemplo n.º 2
0
        public void GivenTheBrokerIsNotAvailable()
        {
            auditStream.ClearLog();

            var config = new ImplementationRunnerConfig()
                         .SetHostname("111")
                         .SetPort(Port)
                         .SetRequestQueueName("X")
                         .SetResponseQueueName("Y")
                         .SetAuditStream(auditStream);

            queueBasedImplementationRunnerBuilder = new QueueBasedImplementationRunner.Builder().SetConfig(config);
            queueBasedImplementationRunner        = queueBasedImplementationRunnerBuilder.Create();
        }
        /// <summary>
        /// ~~~~~~~~~~ Running the system: ~~~~~~~~~~~~~
        ///
        ///   From IDE:
        ///      Configure the "BeFaster.App" solution to Run on External Console then run.
        ///
        ///   From command line:
        ///      msbuild befaster.sln; src\BeFaster.App\bin\Debug\BeFaster.App.exe
        ///
        ///   To run your unit tests locally:
        ///      Run the "BeFaster.App.Tests - Unit Tests" configuration.
        ///
        /// ~~~~~~~~~~ The workflow ~~~~~~~~~~~~~
        ///
        ///   By running this file you interact with a challenge server.
        ///   The interaction follows a request-response pattern:
        ///        * You are presented with your current progress and a list of actions.
        ///        * You trigger one of the actions by typing it on the console.
        ///        * After the action feedback is presented, the execution will stop.
        ///
        ///   +------+-------------------------------------------------------------+
        ///   | Step | The usual workflow                                          |
        ///   +------+-------------------------------------------------------------+
        ///   |  1.  | Run this file.                                              |
        ///   |  2.  | Start a challenge by typing "start".                        |
        ///   |  3.  | Read description from the "challenges" folder               |
        ///   |  4.  | Implement the required method in                            |
        ///   |      |   .\src\BeFaster.App\Solutions                              |
        ///   |  5.  | Deploy to production by typing "deploy".                    |
        ///   |  6.  | Observe output, check for failed requests.                  |
        ///   |  7.  | If passed, go to step 3.                                    |
        ///   +------+-------------------------------------------------------------+
        ///
        ///   You are encouraged to change this project as you please:
        ///        * You can use your preferred libraries.
        ///        * You can use your own test framework.
        ///        * You can change the file structure.
        ///        * Anything really, provided that this file stays runnable.
        ///
        /// </summary>
        /// <param name="args">Action.</param>
        private static void Main(string[] args)
        {
            var runner = new QueueBasedImplementationRunner.Builder()
                         .SetConfig(Utils.GetRunnerConfig())
                         .WithSolutionFor("sum", p => SumSolution.Sum(p[0].AsInt(), p[1].AsInt()))
                         .WithSolutionFor("hello", p => HelloSolution.Hello(p[0]))
                         .WithSolutionFor("fizz_buzz", p => FizzBuzzSolution.FizzBuzz(p[0].AsInt()))
                         .WithSolutionFor("checkout", p => CheckoutSolution.Checkout(p[0]))
                         .Create();

            ChallengeSession.ForRunner(runner)
            .WithConfig(Utils.GetConfig())
            .WithActionProvider(new UserInputAction(args))
            .Start();

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey();
        }
Exemplo n.º 4
0
        /// <summary>
        /// ~~~~~~~~~~ Running the system: ~~~~~~~~~~~~~
        ///
        ///   From IDE:
        ///      Configure the "BeFaster.App" solution to Run on External Console then run.
        ///
        ///   From command line:
        ///      msbuild befaster.sln; src\BeFaster.App\bin\Debug\BeFaster.App.exe
        ///        or
        ///      msbuild befaster.sln; mono src/BeFaster.App/bin/Debug/BeFaster.App.exe
        ///
        ///   To run your unit tests locally:
        ///      Run the "BeFaster.App.Tests - Unit Tests" configuration.
        ///
        /// ~~~~~~~~~~ The workflow ~~~~~~~~~~~~~
        ///
        ///   By running this file you interact with a challenge server.
        ///   The interaction follows a request-response pattern:
        ///        * You are presented with your current progress and a list of actions.
        ///        * You trigger one of the actions by typing it on the console.
        ///        * After the action feedback is presented, the execution will stop.
        ///
        ///   +------+-------------------------------------------------------------+
        ///   | Step | The usual workflow                                          |
        ///   +------+-------------------------------------------------------------+
        ///   |  1.  | Run this file.                                              |
        ///   |  2.  | Start a challenge by typing "start".                        |
        ///   |  3.  | Read description from the "challenges" folder               |
        ///   |  4.  | Implement the required method in                            |
        ///   |      |   .\src\BeFaster.App\Solutions                              |
        ///   |  5.  | Deploy to production by typing "deploy".                    |
        ///   |  6.  | Observe output, check for failed requests.                  |
        ///   |  7.  | If passed, go to step 3.                                    |
        ///   +------+-------------------------------------------------------------+
        ///
        ///   You are encouraged to change this project as you please:
        ///        * You can use your preferred libraries.
        ///        * You can use your own test framework.
        ///        * You can change the file structure.
        ///        * Anything really, provided that this file stays runnable.
        ///
        /// </summary>
        /// <param name="args">Action.</param>
        private static void Main(string[] args)
        {
            var runner = new QueueBasedImplementationRunner.Builder().
                         SetConfig(Utils.GetRunnerConfig()).
                         WithSolutionFor("sum", (List <JToken> p) => SumSolution.Sum(p[0].ToObject <int>(), p[1].ToObject <int>())).
                         WithSolutionFor("hello", (List <JToken> p) => HelloSolution.Hello(p[0].ToObject <string>())).
                         WithSolutionFor("array_sum", (List <JToken> p) => ArraySumSolution.Compute((p[0].ToObject <List <int> >()))).
                         WithSolutionFor("int_range", (List <JToken> p) => IntRangeSolution.Generate(p[0].ToObject <int>(), p[1].ToObject <int>())).
                         WithSolutionFor("fizz_buzz", (List <JToken> p) => FizzBuzzSolution.FizzBuzz(p[0].ToObject <int>())).
                         WithSolutionFor("checkout", (List <JToken> p) => CheckoutSolution.Checkout(p[0].ToObject <string>())).
                         Create();

            ChallengeSession.ForRunner(runner)
            .WithConfig(Utils.GetConfig())
            .WithActionProvider(new UserInputAction(args))
            .Start();

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey();
        }