/// <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); }
/// <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 void QDeal() { Assert.AreEqual(110, CheckoutSolution.Checkout("QQQQ")); }
public void SpecialOfferBasketA() { Assert.AreEqual(180, CheckoutSolution.Checkout("AAAA")); }
public void CheckoutIsInvalid() { Assert.AreEqual(-1, CheckoutSolution.Checkout("123")); }
public void NMDeal2() { Assert.AreEqual(175, CheckoutSolution.Checkout("NNNNMM")); }
public void LowerCaseNotAllowed() { Assert.AreEqual(-1, CheckoutSolution.Checkout("a")); }
public void MultipleBasketENoB() { Assert.AreEqual(80, CheckoutSolution.Checkout("EE")); }
public void CheckSTXYZSingle1() { Assert.AreEqual(40, CheckoutSolution.Checkout("ST")); }
public void MultipleSkuBasketD() { Assert.AreEqual(60, CheckoutSolution.Checkout("DDDD")); }
public void VDeal2() { Assert.AreEqual(220, CheckoutSolution.Checkout("VVVVV")); }
public void CheckoutEmptyBasket() { Assert.AreEqual(0, CheckoutSolution.Checkout("")); }
public void UDeal2() { Assert.AreEqual(120, CheckoutSolution.Checkout("UUU")); }
public void RQDeal2() { Assert.AreEqual(260, CheckoutSolution.Checkout("QQQRRRR")); }
public void RQDeal1() { Assert.AreEqual(200, CheckoutSolution.Checkout("RRRR")); }
public void SpecialOfferBasketB() { Assert.AreEqual(45, CheckoutSolution.Checkout("BB")); }
public void CheckSTXYZSingle2() { Assert.AreEqual(37, CheckoutSolution.Checkout("XY")); }
public void MultipleSkuBasketC() { Assert.AreEqual(80, CheckoutSolution.Checkout("CCCC")); }
public void CheckSTXYZSingle3() { Assert.AreEqual(21, CheckoutSolution.Checkout("Z")); }
public void UnorderedBasket() { Assert.AreEqual(245, CheckoutSolution.Checkout("DACDBCADA")); }
public void CheckSTXYZDeal1() { Assert.AreEqual(82, CheckoutSolution.Checkout("STXYZ")); }
public void SimpleBasketE() { Assert.AreEqual(40, CheckoutSolution.Checkout("E")); }
public void CheckSTXYZDeal3() { Assert.AreEqual(135, CheckoutSolution.Checkout("STXYYYZZZ")); }
public void FreeBBasketEvenE() { Assert.AreEqual(80, CheckoutSolution.Checkout("EEB")); }
public void NMDeal1() { Assert.AreEqual(120, CheckoutSolution.Checkout("NNN")); }
public void FreeBBasketOddB() { Assert.AreEqual(165, CheckoutSolution.Checkout("EEEBBB")); }
public void MultipleSkuBasketA() { Assert.AreEqual(100, CheckoutSolution.Checkout("AA")); }
public void SimpleBasket() { Assert.AreEqual(185, CheckoutSolution.Checkout("ABCDK")); }
public void PDeal() { Assert.AreEqual(250, CheckoutSolution.Checkout("PPPPPP")); }