public int ComputeSum_WhenInputIsValid(int x, int y)
        {
            //When
            var result = SumSolution.Sum(x, y);

            // Then
            return(result);
        }
        public void ShouldReturnMinus1_When_InvalidInput(int x, int y)
        {
            // When
            var result = SumSolution.Sum(x, y);

            // then
            Assert.AreEqual(-1, result);
        }
Beispiel #3
0
 public void TestNumbersValidationSum(int x, int y)
 {
     try
     {
         int n = SumSolution.Sum(x, y);
     }
     catch (NumberOutOfRangeException e)
     {
         Assert.Pass(e.Message);
     }
 }
Beispiel #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
 ///
 ///   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.                                    |
 ///   +------+-------------------------------------------------------------+
 ///
 /// </summary>
 /// <param name="args">Action.</param>
 private static void Main(string[] args)
 {
     ClientRunner
     .ForUsername(CredentialsConfigFile.Get("tdl_username"))
     .WithServerHostname(CredentialsConfigFile.Get("tdl_hostname"))
     .WithActionIfNoArgs(RunnerAction.TestConnectivity)
     .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]))
     .Start(args);
 }
        public void ComputeSumInvalidLowerValueInputy()
        {
            // Arrange
            int x = 1;
            int y = -1;

            // Assert
            Assert.Throws <ArgumentException>(() =>
            {
                // Act
                SumSolution.Sum(x, y);
            });
        }
        /// <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();
        }
Beispiel #7
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();
        }
 public int ComputeSumBothMinimun(int x, int y)
 {
     return(SumSolution.Sum(x, y));
 }
Beispiel #9
0
 public void Sum_GivenValueOutofRange_ThrowException(int x, int y)
 {
     NUnit.Framework.Assert.Throws <ArgumentOutOfRangeException>(() => SumSolution.Sum(x, y));
 }
Beispiel #10
0
 public int ComputeSum_RangeTest4(int x, int y)
 {
     return(SumSolution.Sum(x, y));
 }
 public int ComputeSum(int x, int y)
 {
     Assert.AreEqual(SumSolution.Sum(x, y), 2);
     return(SumSolution.Sum(x, y));
 }
 public int ComputeSum(int valueOne, int valueTwo)
 {
     return(SumSolution.Sum(valueOne, valueTwo));
 }
 public void NegativeValueCheck(int x, int y)
 {
     Assert.Throws(typeof(ArgumentException), () => SumSolution.Sum(-1, 0));
 }
 public void ComputeSum(int x, int y)
 {
     Assert.AreEqual(SumSolution.Sum(x, y), 2);
 }
 public int ComputeSum(int x, int y)
 {
     return(SumSolution.Sum(x, y));
 }
 public void ComputeSumSecondAbove()
 {
     Assert.Throws <System.ArgumentOutOfRangeException>(() => SumSolution.Sum(0, 101));
 }
 public void ShouldValidateParameters(int x, int y)
 {
     Assert.Throws <ArgumentOutOfRangeException>(delegate { SumSolution.Sum(x, y); });
 }
 public void ComputeSumFirstBelow()
 {
     Assert.Throws <System.ArgumentOutOfRangeException>(() => SumSolution.Sum(-1, 100));
 }
 public int ComputeSum_Y_invalidrange_higher(int x, int y)
 {
     return(SumSolution.Sum(x, y));
 }