/// <summary> /// ~~~~~~~~~~ Running the system: ~~~~~~~~~~~~~ /// /// From IDE, run without args: /// Set the value of the `WithActionIfNoArgs` below /// Run this project from the IDE. /// /// From IDE, run with args: /// Create a separate Run configuration /// Add the name of the action as an argument to the command-line /// Run the newly created configuration from the IDE. /// /// Available actions: /// * getNewRoundDescription - Get the round description (call once per round). /// * testConnectivity - Test you can connect to the server (call any number of time) /// * deployToProduction - Release your code. Real requests will be used to test your solution. /// If your solution is wrong you get a penalty of 10 minutes. /// After you fix the problem, you should deploy a new version into production. /// /// ~~~~~~~~~~ The workflow ~~~~~~~~~~~~~ /// /// +------+-----------------------------------------+-----------------------------------------------+ /// | Step | IDE | Web console | /// +------+-----------------------------------------+-----------------------------------------------+ /// | 1. | | Start a challenge, should display "Started" | /// | 2. | Run "getNewRoundDescription" | | /// | 3. | Read description from ./challenges | | /// | 4. | Implement the required method in | | /// | | ./src/BeFaster.App/Solutions | | /// | 5. | Run "testConnectivity", observe output | | /// | 6. | If ready, run "deployToProduction" | | /// | 7. | | Type "done" | /// | 8. | | Check failed requests | /// | 9. | | Go to step 2. | /// +------+-----------------------------------------+-----------------------------------------------+ /// /// </summary> /// <param name="args">Action.</param> private static void Main(string[] args) { ClientRunner .ForUsername(CredentialsConfigFile.Get("tdl_username")) .WithServerHostname("run.befaster.io") .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(); }
/// <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 ComputeSum(int x, int y) { return(SumSolution.Sum(x, y)); }
public int ComputeSum_RangeTest4(int x, int y) { return(SumSolution.Sum(x, y)); }
public int ComputeSum(int valueOne, int valueTwo) { return(SumSolution.Sum(valueOne, valueTwo)); }
public int ComputeSum(int x, int y) { Assert.AreEqual(SumSolution.Sum(x, y), 2); return(SumSolution.Sum(x, y)); }
public void NegativeValueCheck(int x, int y) { Assert.Throws(typeof(ArgumentException), () => SumSolution.Sum(-1, 0)); }
public int ComputeSumBothMinimun(int x, int y) { return(SumSolution.Sum(x, y)); }
public void ComputeSumFirstBelow() { Assert.Throws <System.ArgumentOutOfRangeException>(() => SumSolution.Sum(-1, 100)); }
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 ComputeSum(int x, int y) { Assert.AreEqual(SumSolution.Sum(x, y), 2); }
public void Sum_GivenValueOutofRange_ThrowException(int x, int y) { NUnit.Framework.Assert.Throws <ArgumentOutOfRangeException>(() => SumSolution.Sum(x, y)); }
public int ComputeSum_Y_invalidrange_higher(int x, int y) { return(SumSolution.Sum(x, y)); }