├── .gitignore ├── Angular-React ├── README.md └── lets-do-it │ ├── .babelrc │ ├── .nvmrc │ ├── package-lock.json │ ├── package.json │ ├── public │ └── index.ejs │ ├── src │ ├── components │ │ ├── app │ │ │ ├── index.js │ │ │ └── template.html │ │ ├── input-task │ │ │ ├── index.js │ │ │ └── template.html │ │ ├── task-item │ │ │ ├── index.js │ │ │ └── template.html │ │ └── task-list │ │ │ ├── index.js │ │ │ └── template.html │ └── index.js │ └── webpack.config.js ├── README.md ├── arduino-mocha ├── .nvmrc ├── README.md ├── arduino.js ├── my-report.js ├── package.json ├── setup.js └── test.js ├── bowling-game ├── README.md └── tabcorp │ ├── 17-05-2017 │ ├── .nvmrc │ ├── README.md │ ├── package.json │ └── test.js │ └── 31-05-2017 │ ├── .nvmrc │ ├── README.md │ ├── package.json │ └── test.js ├── counter-react ├── README.md └── index.html ├── equal-sides-of-an-array ├── README.md ├── package.json └── test.js ├── es6-promise ├── .nvmrc ├── 1-basics.js ├── 2-creation.js ├── 3-chaining.js ├── 4-api.js ├── 5-catch.js ├── README.md └── package.json ├── from-callback-to-promise └── README.md ├── game-of-life ├── README.md └── oneflare │ ├── .gitignore │ ├── .rspec │ ├── .ruby-version │ ├── Gemfile │ ├── Gemfile.lock │ ├── README.md │ ├── Rakefile │ └── game_of_life.rb ├── gilded-rose-refactoring-kata ├── GildedRoseRequirements.txt ├── README.md ├── license.txt ├── sbs │ ├── README.md │ ├── SpecRunner.html │ ├── TexttestFixture.html │ ├── lib │ │ ├── jasmine-1.1.0 │ │ │ ├── MIT.LICENSE │ │ │ ├── jasmine-html.js │ │ │ ├── jasmine.css │ │ │ ├── jasmine.js │ │ │ └── jasmine_favicon.png │ │ ├── jasmine-ajax │ │ │ └── mock-ajax.js │ │ ├── jasmine-jquery-1.3.1 │ │ │ └── jasmine-jquery-1.3.1.js │ │ └── jquery-1.7.1 │ │ │ └── jquery-1.7.1.js │ ├── spec │ │ └── gilded_rose_spec.js │ └── src │ │ └── gilded_rose.js └── tabcorp │ ├── README.md │ ├── TexttestFixture.html │ ├── index.html │ ├── lib │ ├── jasmine-1.1.0 │ │ ├── MIT.LICENSE │ │ ├── jasmine-html.js │ │ ├── jasmine.css │ │ ├── jasmine.js │ │ └── jasmine_favicon.png │ ├── jasmine-ajax │ │ └── mock-ajax.js │ ├── jasmine-jquery-1.3.1 │ │ └── jasmine-jquery-1.3.1.js │ └── jquery-1.7.1 │ │ └── jquery-1.7.1.js │ ├── spec │ └── gilded_rose_spec.js │ └── src │ └── gilded_rose.js ├── microfrontends ├── README.md └── tabcorp │ ├── .gitignore │ ├── README.md │ ├── cart │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── Main.elm │ ├── bootstrap.js │ ├── build.sh │ ├── elm-package.json │ ├── index.html │ ├── package-lock.json │ └── package.json │ ├── header │ ├── .babelrc │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ └── manifest.json │ ├── server.js │ └── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ └── registerServiceWorker.js │ ├── homepage │ ├── package-lock.json │ ├── package.json │ ├── server.js │ └── views │ │ └── index.ejs │ └── products-list │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── config │ ├── env.js │ ├── jest │ │ ├── cssTransform.js │ │ └── fileTransform.js │ ├── paths.js │ ├── polyfills.js │ ├── webpack.config.dev.js │ └── webpack.config.prod.js │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ └── index.html │ ├── scripts │ ├── build.js │ ├── start.js │ └── test.js │ ├── server.js │ └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ └── logo.svg ├── racing-car-katas ├── README.md ├── exercises │ ├── CSharp │ │ ├── LeaderBoard │ │ │ ├── Driver.cs │ │ │ ├── Leaderboard.cs │ │ │ ├── Race.cs │ │ │ └── SelfDrivingCar.cs │ │ ├── Leaderboard.Tests │ │ │ ├── LeaderboardTest.cs │ │ │ ├── RaceTest.cs │ │ │ └── TestData.cs │ │ ├── TDDMicroExercises.csproj │ │ ├── TDDMicroExercises.sln │ │ ├── TelemetrySystem.Tests │ │ │ └── TelemetryDiagnosticControlsTest.cs │ │ ├── TelemetrySystem │ │ │ ├── TelemetryClient.cs │ │ │ └── TelemetryDiagnosticControls.cs │ │ ├── TirePressureMonitoringSystem.Tests │ │ │ └── AlarmTest.cs │ │ ├── TirePressureMonitoringSystem │ │ │ ├── Alarm.cs │ │ │ └── Sensor.cs │ │ ├── TurnTicketDispenser │ │ │ ├── TicketDispenser.cs │ │ │ ├── TurnNumberSequence.cs │ │ │ └── TurnTicket.cs │ │ ├── UnicodeFileToHtmlTextConverter.Tests │ │ │ └── UnicodeFileToHtmlTextConverterTest.cs │ │ ├── UnicodeFileToHtmlTextConverter │ │ │ └── UnicodeFileToHtmlTextConverter.cs │ │ └── packages.config │ ├── Cpp │ │ ├── .gitignore │ │ ├── README.md │ │ ├── Source │ │ │ ├── CMakeLists.txt │ │ │ ├── CMakeModules │ │ │ │ └── FindCppUnit.cmake │ │ │ ├── LeaderBoard.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ └── TestData.h │ │ │ │ └── source │ │ │ │ │ ├── LeaderBoardTest.cpp │ │ │ │ │ ├── RaceTest.cpp │ │ │ │ │ ├── TestData.cpp │ │ │ │ │ └── main.cpp │ │ │ ├── LeaderBoard │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── Driver.h │ │ │ │ │ ├── LeaderBoard.h │ │ │ │ │ ├── Race.h │ │ │ │ │ └── SelfDrivingCar.h │ │ │ │ └── source │ │ │ │ │ ├── Driver.cpp │ │ │ │ │ ├── LeaderBoard.cpp │ │ │ │ │ ├── Race.cpp │ │ │ │ │ └── SelfDrivingCar.cpp │ │ │ ├── TelemetrySystem.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── TelemetryDiagnosticControlsTest.cpp │ │ │ │ │ └── main.cpp │ │ │ ├── TelemetrySystem │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── TelemetryClient.h │ │ │ │ │ └── TelemetryDiagnosticControls.h │ │ │ │ └── source │ │ │ │ │ ├── TelemetryClient.cpp │ │ │ │ │ └── TelemetryDiagnosticControls.cpp │ │ │ ├── TextConverter.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── HtmlPagesConverterTest.cpp │ │ │ │ │ ├── HtmlTextConverterTest.cpp │ │ │ │ │ └── main.cpp │ │ │ ├── TextConverter │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── HtmlPagesConverter.h │ │ │ │ │ ├── HtmlTextConverter.h │ │ │ │ │ └── StringEscapeUtils.h │ │ │ │ └── source │ │ │ │ │ ├── HtmlPagesConverter.cpp │ │ │ │ │ └── HtmlTextConverter.cpp │ │ │ ├── TirePressureMonitoring.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── AlarmTest.cpp │ │ │ │ │ └── main.cpp │ │ │ ├── TirePressureMonitoring │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── Alarm.h │ │ │ │ │ └── Sensor.h │ │ │ │ └── source │ │ │ │ │ ├── Alarm.cpp │ │ │ │ │ └── Sensor.cpp │ │ │ ├── TurnTicketDispenser.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── TurnTicketDispenserTest.cpp │ │ │ │ │ └── main.cpp │ │ │ └── TurnTicketDispenser │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ ├── TicketDispenser.h │ │ │ │ ├── TurnNumberSequence.h │ │ │ │ └── TurnTicket.h │ │ │ │ └── source │ │ │ │ ├── TicketDispenser.cpp │ │ │ │ ├── TurnNumberSequence.cpp │ │ │ │ └── TurnTicket.cpp │ │ ├── cmake_version │ │ │ └── Source │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CMakeModules │ │ │ │ └── FindCppUnit.cmake │ │ │ │ ├── LeaderBoard.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ └── TestData.h │ │ │ │ └── source │ │ │ │ │ ├── LeaderBoardTest.cpp │ │ │ │ │ ├── RaceTest.cpp │ │ │ │ │ ├── TestData.cpp │ │ │ │ │ └── main.cpp │ │ │ │ ├── LeaderBoard │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── Driver.h │ │ │ │ │ ├── LeaderBoard.h │ │ │ │ │ ├── Race.h │ │ │ │ │ └── SelfDrivingCar.h │ │ │ │ └── source │ │ │ │ │ ├── Driver.cpp │ │ │ │ │ ├── LeaderBoard.cpp │ │ │ │ │ ├── Race.cpp │ │ │ │ │ └── SelfDrivingCar.cpp │ │ │ │ ├── TelemetrySystem.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── TelemetryDiagnosticControlsTest.cpp │ │ │ │ │ └── main.cpp │ │ │ │ ├── TelemetrySystem │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── TelemetryClient.h │ │ │ │ │ └── TelemetryDiagnosticControls.h │ │ │ │ └── source │ │ │ │ │ ├── TelemetryClient.cpp │ │ │ │ │ └── TelemetryDiagnosticControls.cpp │ │ │ │ ├── TextConverter.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── HtmlPagesConverterTest.cpp │ │ │ │ │ ├── HtmlTextConverterTest.cpp │ │ │ │ │ └── main.cpp │ │ │ │ ├── TextConverter │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── HtmlPagesConverter.h │ │ │ │ │ ├── HtmlTextConverter.h │ │ │ │ │ └── StringEscapeUtils.h │ │ │ │ └── source │ │ │ │ │ ├── HtmlPagesConverter.cpp │ │ │ │ │ └── HtmlTextConverter.cpp │ │ │ │ ├── TirePressureMonitoring.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── AlarmTest.cpp │ │ │ │ │ └── main.cpp │ │ │ │ ├── TirePressureMonitoring │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── Alarm.h │ │ │ │ │ └── Sensor.h │ │ │ │ └── source │ │ │ │ │ ├── Alarm.cpp │ │ │ │ │ └── Sensor.cpp │ │ │ │ ├── TurnTicketDispenser.Test │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── source │ │ │ │ │ ├── TurnTicketDispenserTest.cpp │ │ │ │ │ └── main.cpp │ │ │ │ └── TurnTicketDispenser │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ ├── TicketDispenser.h │ │ │ │ ├── TurnNumberSequence.h │ │ │ │ └── TurnTicket.h │ │ │ │ └── source │ │ │ │ ├── TicketDispenser.cpp │ │ │ │ ├── TurnNumberSequence.cpp │ │ │ │ └── TurnTicket.cpp │ │ ├── gmock_version │ │ │ ├── textconverter │ │ │ │ ├── HtmlTextConverter.cpp │ │ │ │ ├── HtmlTextConverter.hpp │ │ │ │ ├── HtmlTextConverter.tests.cpp │ │ │ │ ├── StreamConverter.cpp │ │ │ │ ├── StreamConverter.hpp │ │ │ │ ├── StreamConverter.tests.cpp │ │ │ │ ├── StringEscapeUtils.hpp │ │ │ │ ├── foo.txt │ │ │ │ ├── instructions.txt │ │ │ │ ├── makefile │ │ │ │ └── test │ │ │ └── tyrepressure │ │ │ │ ├── Alarm.cpp │ │ │ │ ├── Alarm.hpp │ │ │ │ ├── Alarm.tests.cpp │ │ │ │ ├── PressureSensor.cpp │ │ │ │ ├── PressureSensor.hpp │ │ │ │ ├── Sensor.hpp │ │ │ │ ├── StubSensor.hpp │ │ │ │ ├── makefile │ │ │ │ └── test │ │ └── gtest_version │ │ │ ├── leaderboard │ │ │ ├── Driver.cpp │ │ │ ├── Driver.hpp │ │ │ ├── Leaderboard.cpp │ │ │ ├── Leaderboard.hpp │ │ │ ├── Leaderboard.tests.cpp │ │ │ ├── Race.cpp │ │ │ ├── Race.hpp │ │ │ ├── Race.tests.cpp │ │ │ ├── SelfDrivingCar.cpp │ │ │ ├── SelfDrivingCar.hpp │ │ │ ├── TestData.cpp │ │ │ ├── TestData.hpp │ │ │ └── makefile │ │ │ ├── telemetrydiagnostics │ │ │ ├── Telemetry.tests.cpp │ │ │ ├── TelemetryClient.cpp │ │ │ ├── TelemetryClient.hpp │ │ │ ├── TelemetryDiagnosticControls.cpp │ │ │ ├── TelemetryDiagnosticControls.hpp │ │ │ └── makefile │ │ │ ├── textconverter │ │ │ ├── HtmlTextConverter.cpp │ │ │ ├── HtmlTextConverter.hpp │ │ │ ├── HtmlTextConverter.tests.cpp │ │ │ ├── StringEscapeUtils.hpp │ │ │ └── makefile │ │ │ ├── turnticket │ │ │ ├── TicketDispenser.cpp │ │ │ ├── TicketDispenser.hpp │ │ │ ├── TicketDispenser.tests.cpp │ │ │ ├── TurnNumberSequence.cpp │ │ │ ├── TurnNumberSequence.hpp │ │ │ ├── TurnTicket.cpp │ │ │ ├── TurnTicket.hpp │ │ │ └── makefile │ │ │ └── tyrepressure │ │ │ ├── Alarm.cpp │ │ │ ├── Alarm.hpp │ │ │ ├── Alarm.tests.cpp │ │ │ ├── Sensor.cpp │ │ │ ├── Sensor.hpp │ │ │ └── makefile │ ├── Java │ │ ├── .gitignore │ │ ├── Leaderboard │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── tddmicroexercises │ │ │ │ │ └── leaderboard │ │ │ │ │ ├── Driver.java │ │ │ │ │ ├── Leaderboard.java │ │ │ │ │ ├── Race.java │ │ │ │ │ └── SelfDrivingCar.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── tddmicroexercises │ │ │ │ └── leaderboard │ │ │ │ ├── LeaderboardTest.java │ │ │ │ ├── RaceTest.java │ │ │ │ └── TestData.java │ │ ├── TelemetrySystem │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── tddmicroexercises │ │ │ │ │ └── telemetrysystem │ │ │ │ │ ├── TelemetryClient.java │ │ │ │ │ └── TelemetryDiagnosticControls.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── tddmicroexercises │ │ │ │ └── telemetrysystem │ │ │ │ └── TelemetryDiagnosticControlsTest.java │ │ ├── TextConverter │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── tddmicroexercises │ │ │ │ │ └── textconvertor │ │ │ │ │ ├── HtmlPagesConverter.java │ │ │ │ │ ├── HtmlTextConverter.java │ │ │ │ │ └── StringEscapeUtils.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── tddmicroexercises │ │ │ │ └── textconvertor │ │ │ │ ├── HtmlPagesConverterTest.java │ │ │ │ └── HtmlTextConverterTest.java │ │ ├── TirePressureMonitoringSystem │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── tddmicroexercises │ │ │ │ │ └── tirepressuremonitoringsystem │ │ │ │ │ ├── Alarm.java │ │ │ │ │ └── Sensor.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── tddmicroexercises │ │ │ │ └── tirepressuremonitoringsystem │ │ │ │ └── TestAlarm.java │ │ └── TurnTicketDispenser │ │ │ ├── pom.xml │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── tddmicroexercises │ │ │ └── turnticketdispenser │ │ │ ├── TicketDispenser.java │ │ │ ├── TurnNumberSequence.java │ │ │ └── TurnTicket.java │ ├── Javascript │ │ ├── .gitignore │ │ ├── lib │ │ │ ├── .gitignore │ │ │ ├── jasmine-html.js │ │ │ ├── jasmine.css │ │ │ ├── jasmine.js │ │ │ └── jsfake.js │ │ ├── spec.runner.html │ │ ├── telemetry-system-tests │ │ │ └── telemetry-diagnostic-controls-test.js │ │ ├── telemetry-system │ │ │ ├── telemetry-client.js │ │ │ └── telemetry-diagnostic-controls.js │ │ ├── tire-pressure-monitoring-system-tests │ │ │ └── alarm-test.js │ │ ├── tire-pressure-monitoring-system │ │ │ ├── alarm.js │ │ │ └── sensor.js │ │ ├── turn-ticket-dispenser-tests │ │ │ └── ticket-dispenser-test.js │ │ ├── turn-ticket-dispenser │ │ │ ├── ticket-dispenser.js │ │ │ ├── turn-number-sequence.js │ │ │ └── turn-ticket.js │ │ ├── unicode-file-to-html-text-converter-tests │ │ │ └── unicode-file-to-html-text-converter-test.js │ │ └── unicode-file-to-html-text-converter │ │ │ └── unicode-file-to-html-text-converter.js │ ├── Python │ │ ├── Leaderboard │ │ │ ├── leaderboard.py │ │ │ └── test_leaderboard.py │ │ ├── TelemetrySystem │ │ │ ├── client.py │ │ │ ├── telemetry.py │ │ │ └── test_telemetry.py │ │ ├── TextConverter │ │ │ ├── html_pages.py │ │ │ ├── test_text_converter.py │ │ │ └── text_converter.py │ │ ├── TirePressureMonitoringSystem │ │ │ ├── sensor.py │ │ │ ├── test_tire_pressure_monitoring.py │ │ │ └── tire_pressure_monitoring.py │ │ └── TurnTicketDispenser │ │ │ ├── test_turn_ticket.py │ │ │ └── turn_ticket.py │ ├── Ruby │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── LeaderBoard │ │ │ ├── leader_board.rb │ │ │ └── spec │ │ │ │ └── leader_board_spec.rb │ │ ├── TelemetrySystem │ │ │ ├── client.rb │ │ │ ├── spec │ │ │ │ └── telemetry_diagnostics_spec.rb │ │ │ └── telemetry.rb │ │ ├── TextConverter │ │ │ ├── html_pages.rb │ │ │ ├── spec │ │ │ │ └── text_converter_spec.rb │ │ │ └── text_converter.rb │ │ ├── TirePressure │ │ │ ├── test_tire_pressure.rb │ │ │ └── tire_pressure.rb │ │ └── TurnTicketDispenser │ │ │ ├── spec │ │ │ └── turn_ticket_spec.rb │ │ │ └── turn_ticket.rb │ └── scala │ │ ├── build.sbt │ │ └── src │ │ ├── main │ │ └── scala │ │ │ └── tddmicroexercises │ │ │ ├── leaderboard │ │ │ ├── Driver.scala │ │ │ ├── Leaderboard.scala │ │ │ └── Race.scala │ │ │ ├── textconvertor │ │ │ ├── HtmlPagesConverter.scala │ │ │ ├── HtmlTextConverter.scala │ │ │ └── StringEscapeUtils.scala │ │ │ ├── tirepressuremonitoringsystem │ │ │ ├── Alarm.scala │ │ │ └── Sensor.scala │ │ │ └── turnticketdispenser │ │ │ ├── TicketDispenser.scala │ │ │ ├── TurnNumberSequence.scala │ │ │ └── TurnTicket.scala │ │ └── test │ │ └── scala │ │ └── tddmicroexercises │ │ ├── leaderboard │ │ └── LeaderboardSpec.scala │ │ ├── textconvertor │ │ ├── HtmlPagesConverterTest.scala │ │ └── HtmlTextConverterTest.scala │ │ └── tirepressuremonitoringsystem │ │ └── TestAlarm.scala ├── license.txt └── tabcorp │ ├── README.md │ ├── lib │ ├── .gitignore │ ├── jasmine-html.js │ ├── jasmine.css │ ├── jasmine.js │ └── jsfake.js │ ├── spec.runner.html │ ├── tire-pressure-monitoring-system-tests │ └── alarm-test.js │ ├── tire-pressure-monitoring-system │ ├── alarm.js │ └── sensor.js │ ├── turn-ticket-dispenser-tests │ └── ticket-dispenser-test.js │ ├── turn-ticket-dispenser │ ├── ticket-dispenser.js │ ├── turn-number-sequence.js │ └── turn-ticket.js │ ├── unicode-file-to-html-text-converter-tests │ └── unicode-file-to-html-text-converter-test.js │ └── unicode-file-to-html-text-converter │ └── unicode-file-to-html-text-converter.js ├── renovate.json ├── require-lint └── README.md ├── revenge-of-the-pancakes ├── README.md ├── package.json └── revenge-of-the-pancakes.js ├── roman-numerals ├── .nvmrc ├── README.md ├── package.json └── test.js ├── tennis-refactoring-kata ├── .nvmrc ├── README.md ├── TennisGame1.js ├── TennisTest.html └── TennisTest.js └── warriorjs ├── README.md └── tabcorp ├── README.md ├── package-lock.json ├── package.json └── warriorjs ├── dojoer-beginner ├── .profile ├── Player.js └── README └── lethaldose-beginner ├── .profile ├── Player.js └── README /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /Angular-React/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** Working with Redux in an Angular App 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 15/11/2017 5 | 6 | ## Kata: Angular App with Redux 7 | 8 | ### Description: 9 | Use an Angular App for creating ToDo List and using the concepts of Redux, build on the logic and make it functional. 10 | 11 | ### Tech Specifications: 12 | - Uses Angular, Redux and Webpack 13 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"], 3 | "plugins": [ 4 | "transform-object-rest-spread", 5 | [ 6 | "babel-plugin-webpack-alias", 7 | { 8 | "config": "./webpack.config.js" 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/.nvmrc: -------------------------------------------------------------------------------- 1 | 8.3.0 2 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lets-do-it", 3 | "version": "1.0.0", 4 | "description": "A Basic to do list app to learn angular with redux", 5 | "main": "./app/app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "webpack-dev-server" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "angular": "^1.6.6", 14 | "redux": "^4.0.0" 15 | }, 16 | "devDependencies": { 17 | "babel-core": "6.26.3", 18 | "babel-loader": "8.0.5", 19 | "babel-plugin-transform-object-rest-spread": "6.26.0", 20 | "babel-plugin-webpack-alias": "2.1.2", 21 | "babel-preset-env": "1.7.0", 22 | "babel-preset-es2015": "6.24.1", 23 | "css-loader": "2.1.0", 24 | "extract-text-webpack-plugin": "3.0.2", 25 | "file-loader": "3.0.1", 26 | "html-webpack-plugin": "3.2.0", 27 | "raw-loader": "1.0.0", 28 | "resolve-url-loader": "3.0.0", 29 | "sass-loader": "7.1.0", 30 | "style-loader": "0.23.1", 31 | "webpack": "4.29.0", 32 | "webpack-dev-server": "3.1.14" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/public/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LetsDoItApp 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/app/index.js: -------------------------------------------------------------------------------- 1 | import template from './template.html'; 2 | 3 | export default { 4 | template 5 | }; 6 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/app/template.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/input-task/index.js: -------------------------------------------------------------------------------- 1 | import template from './template.html'; 2 | 3 | export default { 4 | template 5 | }; 6 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/input-task/template.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 7 |
8 |
9 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/task-item/index.js: -------------------------------------------------------------------------------- 1 | import template from './template.html'; 2 | 3 | Controller.$inject = ['store']; 4 | 5 | const taskDone = payload => ({ type: 'TASK_DONE', payload }); 6 | 7 | function Controller(store) { 8 | return { 9 | markAsDone (id) { 10 | store.dispatch(taskDone({ id })); 11 | } 12 | } 13 | } 14 | 15 | 16 | export default { 17 | template, 18 | controller: Controller, 19 | bindings: { 20 | description: '<', 21 | done: '<', 22 | id: '<' 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/task-item/template.html: -------------------------------------------------------------------------------- 1 |
2 | {{ ::$ctrl.description }} 3 | 9 | 10 |
11 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/task-list/index.js: -------------------------------------------------------------------------------- 1 | import template from './template.html'; 2 | 3 | controller.$inject = ['store']; 4 | function controller(store) { 5 | return { 6 | tasks: [...store.getState().tasks] 7 | } 8 | } 9 | 10 | export default { 11 | template, 12 | controller 13 | }; 14 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/components/task-list/template.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Angular-React/lets-do-it/src/index.js: -------------------------------------------------------------------------------- 1 | import angular from 'angular'; 2 | import { createStore } from 'redux'; 3 | import app from './components/app'; 4 | import inputTask from './components/input-task'; 5 | import taskList from './components/task-list'; 6 | import taskItem from './components/task-item'; 7 | 8 | const todoAppModule = angular.module('todoApp', []); 9 | 10 | const rootReducer = (state = { 11 | tasks: [ 12 | { id: 1, description: 'Buy milk', done: false }, 13 | { id: 2, description: 'Buy bread', done: true }, 14 | ] 15 | }, {type, payload}) => { 16 | switch (type) { 17 | case 'TASK_DONE': 18 | return { 19 | ...state, 20 | tasks: state.tasks.map(task => { 21 | if (task.id === payload.id) { 22 | task.done = true; 23 | } 24 | return task; 25 | }) 26 | }; 27 | default: 28 | return state 29 | 30 | } 31 | 32 | }; 33 | 34 | const store = createStore(rootReducer); 35 | 36 | todoAppModule.service('store', () => store); 37 | todoAppModule.component('app', app); 38 | todoAppModule.component('inputTask', inputTask); 39 | todoAppModule.component('taskList', taskList); 40 | todoAppModule.component('taskItem', taskItem); 41 | 42 | -------------------------------------------------------------------------------- /arduino-mocha/.nvmrc: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /arduino-mocha/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** Arduino - Mocha 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 10/05/2017 5 | 6 | 7 | 8 | 9 | 10 | ## Kata: Arduino - Mocha 11 | 12 | ### Description: 13 | 14 | The goal is to turn on the green light when all tests are passing, otherwise we need to turn on the red light. 15 | -------------------------------------------------------------------------------- /arduino-mocha/arduino.js: -------------------------------------------------------------------------------- 1 | const five = require("johnny-five"); 2 | 3 | before((done) => { 4 | if (global.board.isReady) 5 | return done(); 6 | global.board.on('ready', done); 7 | }); 8 | -------------------------------------------------------------------------------- /arduino-mocha/my-report.js: -------------------------------------------------------------------------------- 1 | const five = require("johnny-five"); 2 | const mocha = require('mocha'); 3 | let leds = []; 4 | 5 | const turnOffLeds = () => { 6 | leds.forEach((led) => led.off()); 7 | }; 8 | 9 | const setGreen = () => { 10 | const ledGreen = leds[1]; 11 | turnOffLeds() 12 | ledGreen.on(); 13 | }; 14 | 15 | const setRed = () => { 16 | const ledRed = leds[0]; 17 | turnOffLeds(); 18 | ledRed.on(); 19 | }; 20 | 21 | module.exports = MyReporter; 22 | function MyReporter(runner) { 23 | mocha.reporters.Base.call(this, runner); 24 | let hasFailures = false; 25 | 26 | runner.on('fail', function() { 27 | hasFailures = true; 28 | }); 29 | 30 | runner.on('end', function(){ 31 | leds = five.Leds([13, 10]); 32 | if (hasFailures) 33 | setRed() 34 | else 35 | setGreen() 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /arduino-mocha/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "arduino_hello_world", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha -R my-report -r setup.js", 8 | "test:watch": "npm test -- --watch" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "johnny-five": "^1.0.0", 14 | "mocha": "^5.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /arduino-mocha/setup.js: -------------------------------------------------------------------------------- 1 | const five = require("johnny-five"); 2 | global.board = new five.Board({repl: false}); 3 | -------------------------------------------------------------------------------- /arduino-mocha/test.js: -------------------------------------------------------------------------------- 1 | require('./arduino'); 2 | const assert = require('assert'); 3 | 4 | describe('foo', () => { 5 | it('works', () => { 6 | assert.equal(false, true) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /bowling-game/tabcorp/17-05-2017/.nvmrc: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /bowling-game/tabcorp/17-05-2017/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bowling-game", 3 | "scripts": { 4 | "test": "mocha -w" 5 | }, 6 | "devDependencies": { 7 | "mocha": "5.2.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bowling-game/tabcorp/31-05-2017/.nvmrc: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /bowling-game/tabcorp/31-05-2017/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bowling-game", 3 | "scripts": { 4 | "test": "mocha -w" 5 | }, 6 | "devDependencies": { 7 | "mocha": "5.2.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /counter-react/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** Working with React without webpack/babel 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 22/02/2018 5 | 6 | ## Kata: React counter without webpack/babel 7 | 8 | ### Description: 9 | Use React in a simple way as we used do in old times with jQuery, just linking the CDN file into our index.html. 10 | We also did a simple redux implementation to lift the app's state to a centralized store. 11 | 12 | ### Tech Specifications: 13 | - Uses React 14 | -------------------------------------------------------------------------------- /equal-sides-of-an-array/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "equal-sides-of-an-array", 3 | "scripts": { 4 | "test": "mocha -w" 5 | }, 6 | "devDependencies": { 7 | "mocha": "5.2.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /es6-promise/.nvmrc: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /es6-promise/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** ES6 Katas - Promise 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 05/04/2017 and 12/04/2017 5 | 6 | 7 | 8 | 9 | 10 | ## Kata: ES6 Katas - Promise 11 | 12 | ### Description: 13 | 14 | Learn ES6 by doing it. Fix failing tests. Keep all learnings. 15 | 16 | **From:** http://es6katas.org/ 17 | -------------------------------------------------------------------------------- /es6-promise/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "es6-promise", 3 | "scripts": { 4 | "test": "mocha *.js -w" 5 | }, 6 | "devDependencies": { 7 | "assert": "1.4.1", 8 | "mocha": "5.2.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /game-of-life/oneflare/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | -------------------------------------------------------------------------------- /game-of-life/oneflare/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /game-of-life/oneflare/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.4.0 2 | -------------------------------------------------------------------------------- /game-of-life/oneflare/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'http://rubygems.org' 4 | 5 | gem 'rake', '~> 12.0.0' 6 | gem 'rspec', '~> 3.6.0' 7 | -------------------------------------------------------------------------------- /game-of-life/oneflare/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | diff-lcs (1.3) 5 | rake (12.0.0) 6 | rspec (3.6.0) 7 | rspec-core (~> 3.6.0) 8 | rspec-expectations (~> 3.6.0) 9 | rspec-mocks (~> 3.6.0) 10 | rspec-core (3.6.0) 11 | rspec-support (~> 3.6.0) 12 | rspec-expectations (3.6.0) 13 | diff-lcs (>= 1.2.0, < 2.0) 14 | rspec-support (~> 3.6.0) 15 | rspec-mocks (3.6.0) 16 | diff-lcs (>= 1.2.0, < 2.0) 17 | rspec-support (~> 3.6.0) 18 | rspec-support (3.6.0) 19 | 20 | PLATFORMS 21 | ruby 22 | 23 | DEPENDENCIES 24 | rake (~> 12.0.0) 25 | rspec (~> 3.6.0) 26 | 27 | BUNDLED WITH 28 | 1.14.6 29 | -------------------------------------------------------------------------------- /game-of-life/oneflare/Rakefile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # frozen_string_literal: true 3 | 4 | require 'bundler' 5 | require 'rake' 6 | require 'rspec/core' 7 | require 'rspec/core/rake_task' 8 | 9 | begin 10 | Bundler.setup(:default, :development) 11 | rescue Bundler::BundlerError => e 12 | $stderr.puts e.message 13 | $stderr.puts 'Run `bundle install` to install missing gems' 14 | exit e.status_code 15 | end 16 | 17 | RSpec::Core::RakeTask.new(:spec) do |spec| 18 | spec.pattern = FileList['*.rb'] 19 | end 20 | 21 | task default: :spec 22 | -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 @emilybache 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/sbs/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** GildedRose Refactoring Kata 3 | * **Where:** [SBS](http://www.sbs.com.au/) 4 | * **When:** 01/01/2018 5 | 6 | 7 | 8 | ### Running 9 | 10 | ```shell 11 | npm i -g live-server 12 | live-server . 13 | ``` 14 | 15 | go to http://127.0.0.1:8080/SpecRunner.html 16 | -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/sbs/lib/jasmine-1.1.0/MIT.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2011 Pivotal Labs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/sbs/lib/jasmine-1.1.0/jasmine_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/gilded-rose-refactoring-kata/sbs/lib/jasmine-1.1.0/jasmine_favicon.png -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/tabcorp/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** GildedRose Refactoring Kata 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 07/06/2017 5 | 6 | 7 | -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/tabcorp/lib/jasmine-1.1.0/MIT.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2011 Pivotal Labs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /gilded-rose-refactoring-kata/tabcorp/lib/jasmine-1.1.0/jasmine_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/gilded-rose-refactoring-kata/tabcorp/lib/jasmine-1.1.0/jasmine_favicon.png -------------------------------------------------------------------------------- /microfrontends/README.md: -------------------------------------------------------------------------------- 1 | ## Kata: Micro frontends 2 | 3 | ### Description: 4 | 5 | Exercising Micro frontends working on Rogério's tutorial. 6 | 7 | **From:** https://medium.com/@_rchaves_/building-microfrontends-part-i-creating-small-apps-710d709b48b7 8 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | build 3 | transpiled 4 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** Micro frontends 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 12/07/2017, 19/07/2017 5 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/.dockerignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | elm-stuff 3 | dist 4 | compiled.js 5 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | elm-stuff 3 | dist 4 | compiled.js 5 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:8@sha256:5aebe186c00da3308c8fde5b3a246d1927a56947a1b51f5c4308b7318adf74f4 2 | 3 | RUN npm -g --unsafe-perm install elm 4 | RUN npm -g install http-server 5 | 6 | COPY elm-package.json . 7 | RUN elm package install --yes 8 | COPY . . 9 | 10 | ENV PUBLIC_URL https://microfrontends.herokuapp.com/cart 11 | 12 | RUN ./build.sh 13 | 14 | CMD http-server -p $PORT dist 15 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/bootstrap.js: -------------------------------------------------------------------------------- 1 | var app = Elm.Cart.embed(document.getElementById('cart-main')); 2 | 3 | window.addEventListener('addToCart', (event) => { 4 | app.ports.addToCartEvents.send(event.detail); 5 | }, false); 6 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/build.sh: -------------------------------------------------------------------------------- 1 | mkdir -p dist 2 | elm make Main.elm --output compiled.js 3 | cat compiled.js bootstrap.js > dist/bundle.js 4 | cat index.html | sed -e "s#dist#$PUBLIC_URL#" > dist/index.html 5 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "5.1.1 <= v < 6.0.0", 12 | "elm-lang/html": "2.0.0 <= v < 3.0.0" 13 | }, 14 | "elm-version": "0.18.0 <= v < 0.19.0" 15 | } 16 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/index.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/cart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cart", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "elm": "0.18.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | transpiled 4 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:8@sha256:5aebe186c00da3308c8fde5b3a246d1927a56947a1b51f5c4308b7318adf74f4 2 | 3 | COPY package.json . 4 | RUN npm install 5 | COPY . . 6 | 7 | ENV PUBLIC_URL http://localhost:3000 8 | 9 | RUN npm run build 10 | RUN npm run transpile 11 | 12 | CMD PORT=$PORT npm run start:prod 13 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "header", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "babel-cli": "6.26.0", 7 | "react": "16.7.0", 8 | "react-dom": "16.7.0", 9 | "react-scripts": "2.1.3" 10 | }, 11 | "scripts": { 12 | "start": "react-scripts start", 13 | "build": "react-scripts build", 14 | "test": "react-scripts test --env=jsdom", 15 | "eject": "react-scripts eject", 16 | "transpile": "NODE_ENV=production babel src --out-dir transpiled --presets react-app", 17 | "start:prod": "NODE_ENV=production node server.js" 18 | }, 19 | "devDependencies": { 20 | "babel-preset-es2015": "6.24.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/microfrontends/tabcorp/header/public/favicon.ico -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/server.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | const express = require('express'); 4 | const React = require('react'); 5 | const App = require('./transpiled/App.js').default; 6 | const { renderToString } = require('react-dom/server'); 7 | 8 | const server = express(); 9 | 10 | server.get('/', (req, res) => { 11 | const htmlPath = path.resolve(__dirname, 'build', 'index.html'); 12 | 13 | fs.readFile(htmlPath, 'utf8', (err, html) => { 14 | const rootElem = '
'; 15 | const renderedApp = renderToString(React.createElement(App, null)); 16 | 17 | res.send(html.replace(rootElem, rootElem + renderedApp)); 18 | }); 19 | }); 20 | 21 | server.use(express.static('build')); 22 | 23 | const port = process.env.PORT || 8080; 24 | server.listen(port, () => { 25 | console.log(`App listening on port ${port}`); 26 | }); 27 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 80px; 8 | } 9 | 10 | .App-header { 11 | background-color: #222; 12 | height: 150px; 13 | padding: 20px; 14 | color: white; 15 | } 16 | 17 | .App-intro { 18 | font-size: large; 19 | } 20 | 21 | @keyframes App-logo-spin { 22 | from { transform: rotate(0deg); } 23 | to { transform: rotate(360deg); } 24 | } 25 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () => 4 |
5 |

Logo

6 | 12 |
; 13 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | }); 9 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/header/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | registerServiceWorker(); 9 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/homepage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "homepage", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "ejs": "^2.5.6", 13 | "express": "^4.15.3", 14 | "request": "^2.81.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/homepage/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const server = express(); 3 | const request = require('request'); 4 | 5 | server.set('view engine', 'ejs'); 6 | 7 | server.get('/', (req, res) => 8 | Promise.all([ 9 | getContents('http://localhost:3002'), 10 | getContents('http://localhost:3001'), 11 | getContents('http://localhost:3000') 12 | ]) 13 | .then(responses => 14 | res.render('index', { 15 | header: responses[0], 16 | productsList: responses[1], 17 | cart: responses[2] 18 | }) 19 | ) 20 | .catch(error => res.send(error.message)) 21 | ); 22 | 23 | const getContents = url => 24 | new Promise((resolve, reject) => { 25 | request.get(url, (error, response, body) => { 26 | if (error) return resolve('Error loading ' + url + ': ' + error.message); 27 | 28 | return resolve(body); 29 | }); 30 | }); 31 | 32 | const port = process.env.PORT || 8080; 33 | server.listen(port, () => { 34 | console.log(`Homepage listening on port ${port}`); 35 | }); 36 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/homepage/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Microfrontends Homepage 7 | 8 | 9 | 10 | <%- header %> 11 | <%- productsList %> 12 | <%- cart %> 13 | 14 | 15 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | /transpiled 12 | 13 | # misc 14 | .DS_Store 15 | .env 16 | npm-debug.log* 17 | yarn-debug.log* 18 | yarn-error.log* 19 | 20 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:latest@sha256:491424526a6556f7698c5d659b55f15d63b63a864c420a1f607d1a9d90b18a4a 2 | 3 | COPY package.json . 4 | RUN npm install 5 | COPY . . 6 | 7 | ENV PUBLIC_URL http://localhost:3002 8 | 9 | RUN npm run build 10 | RUN npm run transpile 11 | 12 | CMD PORT=$PORT npm run start:prod 13 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This is a custom Jest transformer turning style imports into empty objects. 4 | // http://facebook.github.io/jest/docs/tutorial-webpack.html 5 | 6 | module.exports = { 7 | process() { 8 | return 'module.exports = {};'; 9 | }, 10 | getCacheKey() { 11 | // The output is always the same. 12 | return 'cssTransform'; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | // This is a custom Jest transformer turning file imports into filenames. 6 | // http://facebook.github.io/jest/docs/tutorial-webpack.html 7 | 8 | module.exports = { 9 | process(src, filename) { 10 | return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/config/polyfills.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | if (typeof Promise === 'undefined') { 4 | // Rejection tracking prevents a common issue where React gets into an 5 | // inconsistent state due to an error, but it gets swallowed by a Promise, 6 | // and the user has no idea what causes React's erratic future behavior. 7 | require('promise/lib/rejection-tracking').enable(); 8 | window.Promise = require('promise/lib/es6-extensions.js'); 9 | } 10 | 11 | // fetch() polyfill for making API calls. 12 | require('whatwg-fetch'); 13 | 14 | // Object.assign() is commonly used with React. 15 | // It will use the native implementation if it's present and isn't buggy. 16 | Object.assign = require('object-assign'); 17 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/microfrontends/tabcorp/products-list/public/favicon.ico -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | React App 17 | 18 | 19 |
20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/scripts/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | process.env.NODE_ENV = 'test'; 4 | process.env.PUBLIC_URL = ''; 5 | 6 | // Load environment variables from .env file. Suppress warnings using silent 7 | // if this file is missing. dotenv will never modify any environment variables 8 | // that have already been set. 9 | // https://github.com/motdotla/dotenv 10 | require('dotenv').config({silent: true}); 11 | 12 | const jest = require('jest'); 13 | const argv = process.argv.slice(2); 14 | 15 | // Watch unless on CI or in coverage mode 16 | if (!process.env.CI && argv.indexOf('--coverage') < 0) { 17 | argv.push('--watch'); 18 | } 19 | 20 | 21 | jest.run(argv); 22 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/server.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | const express = require('express'); 4 | const React = require('react'); 5 | const App = require('./transpiled/App.js').default; 6 | const { renderToString } = require('react-dom/server'); 7 | 8 | const server = express(); 9 | 10 | server.get('/', (req, res) => { 11 | const htmlPath = path.resolve(__dirname, 'build', 'index.html'); 12 | 13 | fs.readFile(htmlPath, 'utf8', (err, html) => { 14 | const rootElem = '
'; 15 | const renderedApp = renderToString(React.createElement(App, null)); 16 | 17 | res.send(html.replace(rootElem, rootElem + renderedApp)); 18 | }); 19 | }); 20 | 21 | server.use(express.static('build')); 22 | 23 | const port = process.env.PORT || 3002; 24 | server.listen(port, () => { 25 | console.log(`App listening on port ${port}`); 26 | }); 27 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 80px; 8 | } 9 | 10 | .App-header { 11 | background-color: #222; 12 | height: 150px; 13 | padding: 20px; 14 | color: white; 15 | } 16 | 17 | .App-intro { 18 | font-size: large; 19 | } 20 | 21 | @keyframes App-logo-spin { 22 | from { transform: rotate(0deg); } 23 | to { transform: rotate(360deg); } 24 | } 25 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const addToCart = (item) => () => { 4 | const event = new CustomEvent('addToCart', { detail: item }); 5 | window.dispatchEvent(event); 6 | } 7 | 8 | const productItemView = (product, index) => { 9 | const price = parseFloat((Math.random() * 100).toFixed(2)); 10 | 11 | return ( 12 |
  • 13 | {product}
    14 | $ {price}
    15 | 16 |
  • 17 | ); 18 | }; 19 | 20 | export default () => 21 |
    22 |

    Products

    23 |
      24 | { ['Rice', 'Beans', 'Fries', 'Steak'].map(productItemView) } 25 |
    26 |
    ; 27 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | }); 9 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /microfrontends/tabcorp/products-list/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | import './index.css'; 5 | 6 | ReactDOM.render( 7 | , 8 | document.getElementById('products-list-root') 9 | ); 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/LeaderBoard/Driver.cs: -------------------------------------------------------------------------------- 1 | namespace TDDMicroExercises.LeaderBoard 2 | { 3 | public class Driver 4 | { 5 | public Driver(string name, string country) 6 | { 7 | Name = name; 8 | Country = country; 9 | } 10 | 11 | public string Name { get; } 12 | public string Country { get; } 13 | 14 | public override int GetHashCode() 15 | { 16 | return Name.GetHashCode()*31 + Country.GetHashCode(); 17 | } 18 | 19 | public override bool Equals(object obj) 20 | { 21 | if (this == obj) 22 | { 23 | return true; 24 | } 25 | if (!(obj is Driver)) 26 | { 27 | return false; 28 | } 29 | var other = (Driver) obj; 30 | return Name.Equals(other.Name) && Country.Equals(other.Country); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/LeaderBoard/SelfDrivingCar.cs: -------------------------------------------------------------------------------- 1 | namespace TDDMicroExercises.LeaderBoard 2 | { 3 | public class SelfDrivingCar : Driver 4 | { 5 | public SelfDrivingCar(string algorithmVersion, string company) : base(algorithmVersion, company) 6 | { 7 | AlgorithmVersion = algorithmVersion; 8 | } 9 | 10 | public string AlgorithmVersion { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/Leaderboard.Tests/RaceTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace TDDMicroExercises.LeaderBoard.Tests 4 | { 5 | public class RaceTest 6 | { 7 | [Test] 8 | public void ShouldCalculateDriverPoints() 9 | { 10 | Assert.AreEqual(25, TestData.Race1.GetPoints(TestData.Driver1)); 11 | Assert.AreEqual(18, TestData.Race1.GetPoints(TestData.Driver2)); 12 | Assert.AreEqual(15, TestData.Race1.GetPoints(TestData.Driver3)); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TDDMicroExercises.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDDMicroExercises", "TDDMicroExercises.csproj", "{BBCF3C67-8E31-48E3-AD2E-8C605E2E07BE}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {BBCF3C67-8E31-48E3-AD2E-8C605E2E07BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {BBCF3C67-8E31-48E3-AD2E-8C605E2E07BE}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {BBCF3C67-8E31-48E3-AD2E-8C605E2E07BE}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {BBCF3C67-8E31-48E3-AD2E-8C605E2E07BE}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TelemetrySystem.Tests/TelemetryDiagnosticControlsTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace TDDMicroExercises.TelemetrySystem.Tests 4 | { 5 | [TestFixture] 6 | public class TelemetryDiagnosticControlsTest 7 | { 8 | [Test] 9 | public void CheckTransmission_should_send_a_diagnostic_message_and_receive_a_status_message_response() 10 | { 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TirePressureMonitoringSystem.Tests/AlarmTest.cs: -------------------------------------------------------------------------------- 1 | 2 | using NUnit.Framework; 3 | 4 | namespace TDDMicroExercises.TirePressureMonitoringSystem 5 | { 6 | [TestFixture] 7 | public class AlarmTest 8 | { 9 | [Test] 10 | public void Foo() 11 | { 12 | Alarm alarm = new Alarm(); 13 | Assert.AreEqual(false, alarm.AlarmOn); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TirePressureMonitoringSystem/Alarm.cs: -------------------------------------------------------------------------------- 1 | namespace TDDMicroExercises.TirePressureMonitoringSystem 2 | { 3 | public class Alarm 4 | { 5 | private const double LowPressureThreshold = 17; 6 | private const double HighPressureThreshold = 21; 7 | 8 | Sensor _sensor = new Sensor(); 9 | 10 | bool _alarmOn = false; 11 | private long _alarmCount = 0; 12 | 13 | 14 | public void Check() 15 | { 16 | double psiPressureValue = _sensor.PopNextPressurePsiValue(); 17 | 18 | if (psiPressureValue < LowPressureThreshold || HighPressureThreshold < psiPressureValue) 19 | { 20 | _alarmOn = true; 21 | _alarmCount += 1; 22 | } 23 | } 24 | 25 | public bool AlarmOn 26 | { 27 | get { return _alarmOn; } 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TirePressureMonitoringSystem/Sensor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TDDMicroExercises.TirePressureMonitoringSystem 4 | { 5 | public class Sensor 6 | { 7 | const double Offset = 16; 8 | 9 | public double PopNextPressurePsiValue() 10 | { 11 | double pressureTelemetryValue; 12 | SamplePressure(out pressureTelemetryValue); 13 | 14 | return Offset + pressureTelemetryValue; 15 | } 16 | 17 | private static void SamplePressure(out double pressureTelemetryValue) 18 | { 19 | // placeholder implementation that simulate a real sensor in a real tire 20 | Random basicRandomNumbersGenerator = new Random(); 21 | pressureTelemetryValue = 6 * basicRandomNumbersGenerator.NextDouble() * basicRandomNumbersGenerator.NextDouble(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TurnTicketDispenser/TicketDispenser.cs: -------------------------------------------------------------------------------- 1 | namespace TDDMicroExercises.TurnTicketDispenser 2 | { 3 | public class TicketDispenser 4 | { 5 | public TurnTicket GetTurnTicket() 6 | { 7 | int newTurnNumber = TurnNumberSequence.GetNextTurnNumber(); 8 | TurnTicket newTurnTicket = new TurnTicket(newTurnNumber); 9 | 10 | return newTurnTicket; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TurnTicketDispenser/TurnNumberSequence.cs: -------------------------------------------------------------------------------- 1 | namespace TDDMicroExercises.TurnTicketDispenser 2 | { 3 | public static class TurnNumberSequence 4 | { 5 | private static int _turnNumber = 0; 6 | 7 | public static int GetNextTurnNumber() 8 | { 9 | return _turnNumber++; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/TurnTicketDispenser/TurnTicket.cs: -------------------------------------------------------------------------------- 1 | namespace TDDMicroExercises.TurnTicketDispenser 2 | { 3 | public class TurnTicket 4 | { 5 | private readonly int _turnNumber; 6 | 7 | public TurnTicket(int turnNumber) 8 | { 9 | _turnNumber = turnNumber; 10 | } 11 | 12 | public int TurnNumber 13 | { 14 | get { return _turnNumber; } 15 | } 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/UnicodeFileToHtmlTextConverter.Tests/UnicodeFileToHtmlTextConverterTest.cs: -------------------------------------------------------------------------------- 1 | 2 | using NUnit.Framework; 3 | namespace TDDMicroExercises.UnicodeFileToHtmlTextConverter 4 | { 5 | [TestFixture] 6 | public class HikerTest 7 | { 8 | [Test] 9 | public void foobar() 10 | { 11 | UnicodeFileToHtmlTextConverter converter = new UnicodeFileToHtmlTextConverter("foobar.txt"); 12 | Assert.AreEqual("fixme", converter.GetFilename()); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/CSharp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/.gitignore: -------------------------------------------------------------------------------- 1 | Bin/ 2 | build/ 3 | **/test/ 4 | *.compiled_hpp 5 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/README.md: -------------------------------------------------------------------------------- 1 | Requirements: 2 | - CMake 3 | - CppUnit 4 | 5 | Use your package manager to install or download: 6 | - cmake from: https://cmake.org 7 | - cppunit from: https://sourceforge.net/projects/cppunit/ 8 | 9 | Binaries are put to "Cpp/Bin" folder. 10 | 11 | Build steps to generate makefiles: 12 | ```sh 13 | cd Racing-Car-Katas/Cpp 14 | mkdir build 15 | cd build 16 | cmake ../Source 17 | make 18 | ``` 19 | 20 | On Windows for VS2012 replace step 4 by: 21 | ```sh 22 | cmake -G"Visual Studio 12" ..\Source 23 | ``` 24 | 25 | On mac for XCode replace step 4 by: 26 | ```sh 27 | cmake -G"XCode" ../Source 28 | ``` 29 | 30 | For Eclipse 4.4 with CDT4 replace step 4 by: 31 | ```sh 32 | cmake -G"Eclipse CDT4 - Unix Makefiles" -D_ECLIPSE_VERSION=4.4 ../Source 33 | ``` 34 | 35 | For CodeBlocks replace step 4 by: 36 | ```sh 37 | cmake -G"CodeBlocks - Unix Makefiles" ../Source 38 | ``` 39 | 40 | For CodeListe replace step 4 by: 41 | ```sh 42 | cmake -G"CodeLite - Unix Makefiles" ../Source 43 | ``` 44 | 45 | google "cmake generators" if you need something else. 46 | 47 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(Racing-Car-Katas) 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) 5 | 6 | IF(NOT CMAKE_BUILD_TYPE) 7 | SET(CMAKE_BUILD_TYPE Debug) 8 | ENDIF() 9 | 10 | GET_FILENAME_COMPONENT( SOURCE_ROOT . ABSOLUTE ) 11 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SOURCE_ROOT}/../Bin) 12 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SOURCE_ROOT}/../Bin) 13 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SOURCE_ROOT}/../Bin) 14 | 15 | find_package(CppUnit REQUIRED) 16 | include_directories(${CPPUNIT_INCLUDE_DIR}) 17 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 18 | 19 | add_compile_options(--std=c++11) 20 | add_compile_options(-Wall) 21 | add_compile_options(-Werror) 22 | 23 | add_subdirectory(TirePressureMonitoring) 24 | add_subdirectory(TirePressureMonitoring.Test) 25 | add_subdirectory(LeaderBoard) 26 | add_subdirectory(LeaderBoard.Test) 27 | add_subdirectory(TelemetrySystem) 28 | add_subdirectory(TelemetrySystem.Test) 29 | add_subdirectory(TurnTicketDispenser) 30 | add_subdirectory(TurnTicketDispenser.Test) 31 | add_subdirectory(TextConverter) 32 | add_subdirectory(TextConverter.Test) 33 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(LeaderBoard.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} LeaderBoard ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard.Test/source/RaceTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TestData.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class RaceTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_CalculateDriverPoints(); 15 | 16 | CPPUNIT_TEST_SUITE(RaceTest); 17 | CPPUNIT_TEST(t_CalculateDriverPoints); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void RaceTest::t_CalculateDriverPoints() 22 | { 23 | CPPUNIT_ASSERT(25 == TestData::race1.getPoints(TestData::driver1)); 24 | CPPUNIT_ASSERT(18 == TestData::race1.getPoints(TestData::driver2)); 25 | CPPUNIT_ASSERT(15 == TestData::race1.getPoints(TestData::driver3)); 26 | } 27 | 28 | CPPUNIT_TEST_SUITE_REGISTRATION(RaceTest); 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard.Test/source/TestData.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TestData.h" 3 | 4 | Driver TestData::driver1("Nico Rosberg", "DE"); 5 | Driver TestData::driver2("Lewis Hamilton", "UK"); 6 | Driver TestData::driver3("Sebastian Vettel", "DE"); 7 | SelfDrivingCar TestData::driver4("1.3", "Acme"); 8 | 9 | Race TestData::race1("Australian Grand Prix", TestData::CreateDriverList(driver1, driver2, driver3)); 10 | Race TestData::race2("Malaysian Grand Prix", TestData::CreateDriverList(driver3, driver2, driver1)); 11 | Race TestData::race3("Chinese Grand Prix", TestData::CreateDriverList(driver2, driver1, driver3)); 12 | Race TestData::race4("Fictional Grand Prix 1", TestData::CreateDriverList(driver1, driver2, driver4)); 13 | Race TestData::race5("Fictional Grand Prix 2", TestData::CreateDriverList(driver4, driver2, driver1)); 14 | Race TestData::race6("Fictional Grand Prix 3", TestData::CreateDriverList(driver2, driver1, driver4)); 15 | 16 | Leaderboard TestData::sampleLeaderboard1(TestData::CreateRaceList(race1, race2, race3)); 17 | Leaderboard TestData::sampleLeaderboard2(TestData::CreateRaceList(race4, race5, race6)); 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(LeaderBoard) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/include/Driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Driver 6 | { 7 | std::string const m_name; 8 | std::string const m_country; 9 | 10 | public: 11 | Driver(std::string const name, std::string const country); 12 | 13 | std::string getName() const; 14 | 15 | std::string getCountry() const; 16 | 17 | bool operator==(Driver const& other) const; 18 | }; 19 | 20 | namespace std 21 | { 22 | template <> 23 | struct hash 24 | { 25 | std::size_t operator()(Driver const& driver) const 26 | { 27 | std::hash< std::string > const hash; 28 | return hash( driver.getName() ) * 31 + hash( driver.getCountry() ); 29 | } 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/include/LeaderBoard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Race.h" 7 | 8 | class Leaderboard 9 | { 10 | std::list m_races; 11 | 12 | public: 13 | Leaderboard(std::list const& races); 14 | 15 | std::map driverResults(); 16 | 17 | std::list driverRankings(); 18 | }; 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/include/Race.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Driver.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class Race 10 | { 11 | static const int POINTS[]; 12 | 13 | std::string m_name; 14 | std::list m_results; 15 | std::unordered_map m_driverNames; 16 | 17 | public: 18 | Race(std::string const& name, std::list const& drivers); 19 | 20 | int position(Driver const& driver); 21 | 22 | int getPoints(Driver driver); 23 | 24 | std::list getResults(); 25 | 26 | std::string getDriverName(Driver driver); 27 | 28 | std::string toString(); 29 | }; 30 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/include/SelfDrivingCar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Driver.h" 4 | 5 | #include 6 | 7 | class SelfDrivingCar : public Driver 8 | { 9 | std::string m_algorithmVersion; 10 | 11 | public: 12 | SelfDrivingCar(std::string algorithmVersion, std::string company); 13 | 14 | std::string getAlgorithmVersion(); 15 | 16 | void setAlgorithmVersion(std::string algorithmVersion); 17 | }; 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/source/Driver.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Driver.h" 2 | 3 | Driver::Driver(std::string const name, std::string const country) : m_name(name), m_country(country) 4 | {} 5 | 6 | std::string Driver::getName() const 7 | { 8 | return m_name; 9 | } 10 | 11 | std::string Driver::getCountry() const 12 | { 13 | return m_country; 14 | } 15 | 16 | bool Driver::operator==(Driver const& other) const 17 | { 18 | if (this == &other) 19 | { 20 | return true; 21 | } 22 | return (m_name.compare(other.m_name) == 0 && m_country.compare(other.m_country) == 0); 23 | } 24 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/source/Race.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/Race.h" 3 | #include "../include/SelfDrivingCar.h" 4 | 5 | #include 6 | 7 | const int Race::POINTS[] = { 25, 18, 15 }; 8 | 9 | Race::Race(std::string const& name, std::list const& drivers) : m_name(name), m_results(drivers) 10 | { 11 | for (Driver& driver : m_results) 12 | { 13 | std::string driverName = driver.getName(); 14 | if (typeid(driver) == typeid(SelfDrivingCar)) 15 | { 16 | driverName = "Self Driving Car - " + driver.getCountry() + " (" + (static_cast(driver)).getAlgorithmVersion() + ")"; 17 | } 18 | m_driverNames[driver] = driverName; 19 | } 20 | } 21 | 22 | int Race::position(Driver const& driver) 23 | { 24 | int count = 0; 25 | for (Driver& d : m_results) 26 | { 27 | if ( d == driver ) 28 | { 29 | break; 30 | } 31 | ++count; 32 | } 33 | return count; 34 | } 35 | 36 | int Race::getPoints(Driver driver) 37 | { 38 | return POINTS[position(driver)]; 39 | } 40 | 41 | std::list Race::getResults() 42 | { 43 | return m_results; 44 | } 45 | 46 | std::string Race::getDriverName(Driver driver) 47 | { 48 | return m_driverNames[driver]; 49 | } 50 | 51 | std::string Race::toString() 52 | { 53 | return m_name; 54 | } 55 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/LeaderBoard/source/SelfDrivingCar.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/SelfDrivingCar.h" 3 | 4 | SelfDrivingCar::SelfDrivingCar(std::string algorithmVersion, std::string company) : Driver(algorithmVersion, company), m_algorithmVersion( algorithmVersion ) 5 | {} 6 | 7 | std::string SelfDrivingCar::getAlgorithmVersion() 8 | { 9 | return m_algorithmVersion; 10 | } 11 | 12 | void SelfDrivingCar::setAlgorithmVersion(std::string algorithmVersion) 13 | { 14 | m_algorithmVersion = algorithmVersion; 15 | } 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TelemetrySystem.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TelemetrySystem ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem.Test/source/TelemetryDiagnosticControlsTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TelemetrySystem/include/TelemetryClient.h" 3 | #include "TelemetrySystem/include/TelemetryDiagnosticControls.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class TelemetryDiagnosticControlsTest : public CppUnit::TestFixture 10 | { 11 | public: 12 | virtual void setUp() {} 13 | virtual void tearDown() {} 14 | 15 | void t_SendDiagnosticMessageAndReceiveStatusResponse(); 16 | 17 | CPPUNIT_TEST_SUITE(TelemetryDiagnosticControlsTest); 18 | CPPUNIT_TEST(t_SendDiagnosticMessageAndReceiveStatusResponse); 19 | CPPUNIT_TEST_SUITE_END(); 20 | }; 21 | 22 | void TelemetryDiagnosticControlsTest::t_SendDiagnosticMessageAndReceiveStatusResponse() 23 | { 24 | TelemetryDiagnosticControls controls; 25 | controls.checkTransmission(); 26 | CPPUNIT_ASSERT(!controls.getDiagnosticInfo().empty()); 27 | } 28 | 29 | CPPUNIT_TEST_SUITE_REGISTRATION(TelemetryDiagnosticControlsTest); 30 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TelemetrySystem) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem/include/TelemetryClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class TelemetryClient 7 | { 8 | bool m_onlineStatus; 9 | std::string m_diagnosticMessageResult; 10 | std::seed_seq m_seed; 11 | std::mt19937 m_generator; 12 | 13 | public: 14 | static std::string const DIAGNOSTIC_MESSAGE; 15 | 16 | TelemetryClient(); 17 | 18 | bool getOnlineStatus(); 19 | 20 | void connect(std::string const& telemetryServerConnectionString); 21 | 22 | void disconnect(); 23 | 24 | void send(std::string const& message); 25 | 26 | std::string receive(); 27 | }; 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem/include/TelemetryDiagnosticControls.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TelemetryClient.h" 4 | 5 | #include 6 | 7 | class TelemetryDiagnosticControls 8 | { 9 | std::string m_diagnosticChannelConnectionString; 10 | TelemetryClient m_telemetryClient; 11 | std::string m_diagnosticInfo; 12 | 13 | public: 14 | TelemetryDiagnosticControls(); 15 | 16 | std::string getDiagnosticInfo(); 17 | 18 | void setDiagnosticInfo(std::string const& diagnosticInfo); 19 | 20 | void checkTransmission(); 21 | }; 22 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TelemetrySystem/source/TelemetryDiagnosticControls.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TelemetryDiagnosticControls.h" 3 | 4 | #include 5 | 6 | TelemetryDiagnosticControls::TelemetryDiagnosticControls() : 7 | m_diagnosticChannelConnectionString( "*111#" ) 8 | ,m_telemetryClient() 9 | ,m_diagnosticInfo() 10 | {} 11 | 12 | std::string TelemetryDiagnosticControls::getDiagnosticInfo() 13 | { 14 | return m_diagnosticInfo; 15 | } 16 | 17 | void TelemetryDiagnosticControls::setDiagnosticInfo(std::string const& diagnosticInfo) 18 | { 19 | m_diagnosticInfo = diagnosticInfo; 20 | } 21 | 22 | void TelemetryDiagnosticControls::checkTransmission() 23 | { 24 | m_diagnosticInfo = ""; 25 | 26 | m_telemetryClient.disconnect(); 27 | 28 | int retryLeft = 3; 29 | while (m_telemetryClient.getOnlineStatus() == false && retryLeft > 0) 30 | { 31 | m_telemetryClient.connect(m_diagnosticChannelConnectionString); 32 | retryLeft -= 1; 33 | } 34 | 35 | if(m_telemetryClient.getOnlineStatus() == false) 36 | { 37 | throw std::invalid_argument("Unable to connect"); 38 | } 39 | 40 | m_telemetryClient.send(TelemetryClient::DIAGNOSTIC_MESSAGE); 41 | m_diagnosticInfo = m_telemetryClient.receive(); 42 | } 43 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TextConverter.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TextConverter ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter.Test/source/HtmlPagesConverterTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TextConverter/include/HtmlPagesConverter.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class HtmlPagesConverterTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_foo(); 15 | 16 | CPPUNIT_TEST_SUITE(HtmlPagesConverterTest); 17 | CPPUNIT_TEST(t_foo); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void HtmlPagesConverterTest::t_foo() 22 | { 23 | HtmlPagesConverter converter("foo"); 24 | CPPUNIT_ASSERT( std::string("fixme").compare( converter.getFilename() ) == 0 ); 25 | } 26 | 27 | CPPUNIT_TEST_SUITE_REGISTRATION(HtmlPagesConverterTest); 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter.Test/source/HtmlTextConverterTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TextConverter/include/HtmlTextConverter.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class HtmlTextConverterTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_foo(); 15 | 16 | CPPUNIT_TEST_SUITE(HtmlTextConverterTest); 17 | CPPUNIT_TEST(t_foo); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void HtmlTextConverterTest::t_foo() 22 | { 23 | HtmlTextConverter converter("foo"); 24 | CPPUNIT_ASSERT( std::string("fixme").compare( converter.getFilename() ) == 0 ); 25 | } 26 | 27 | CPPUNIT_TEST_SUITE_REGISTRATION(HtmlTextConverterTest); 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TextConverter) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter/include/HtmlPagesConverter.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class HtmlPagesConverter 6 | { 7 | std::string m_filename; 8 | std::vector m_breaks; 9 | 10 | public: 11 | HtmlPagesConverter(std::string const& filename); 12 | 13 | std::string getHtmlPage(int page); 14 | 15 | std::string getFilename(); 16 | }; 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter/include/HtmlTextConverter.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class HtmlTextConverter 6 | { 7 | std::string m_fullFilenameWithPath; 8 | 9 | public: 10 | HtmlTextConverter(std::string const& fullFilenameWithPath); 11 | 12 | std::string convertToHtml(); 13 | 14 | std::string getFilename(); 15 | }; 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter/include/StringEscapeUtils.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class StringEscapeUtils 6 | { 7 | public: 8 | static std::string escapeHtml(std::string const& input) 9 | { 10 | std::string output = input; 11 | output = std::regex_replace(output, std::regex("[&]"), "&"); 12 | output = std::regex_replace(output, std::regex("[<]"), "<"); 13 | output = std::regex_replace(output, std::regex("[>]"), ">"); 14 | output = std::regex_replace(output, std::regex("[\"]"), """); 15 | output = std::regex_replace(output, std::regex("[']"), """); 16 | return output; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TextConverter/source/HtmlTextConverter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/HtmlTextConverter.h" 3 | #include "../include/StringEscapeUtils.h" 4 | 5 | HtmlTextConverter::HtmlTextConverter(std::string const& fullFilenameWithPath) : m_fullFilenameWithPath(fullFilenameWithPath) 6 | {} 7 | 8 | std::string HtmlTextConverter::convertToHtml() 9 | { 10 | std::ifstream reader(m_fullFilenameWithPath); 11 | 12 | std::string line; 13 | std::string html; 14 | while (std::getline(reader,line)) 15 | { 16 | html += StringEscapeUtils::escapeHtml(line); 17 | html += "
    "; 18 | } 19 | return html; 20 | } 21 | 22 | std::string HtmlTextConverter::getFilename() 23 | { 24 | return m_fullFilenameWithPath; 25 | } 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TirePressureMonitoring.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TirePressureMonitoring ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring.Test/source/AlarmTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TirePressureMonitoring/include/Alarm.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | ///< \todo Remove/Clean-up before final commit 9 | 10 | class AlarmTest : public CppUnit::TestFixture 11 | { 12 | public: 13 | virtual void setUp() {} 14 | virtual void tearDown() {} 15 | 16 | void t_FirstTest(); 17 | 18 | CPPUNIT_TEST_SUITE(AlarmTest); 19 | CPPUNIT_TEST(t_FirstTest); 20 | CPPUNIT_TEST_SUITE_END(); 21 | }; 22 | 23 | void AlarmTest::t_FirstTest() 24 | { 25 | CPPUNIT_ASSERT(false); 26 | } 27 | 28 | CPPUNIT_TEST_SUITE_REGISTRATION(AlarmTest); 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TirePressureMonitoring) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring/include/Alarm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sensor.h" 4 | 5 | class Alarm 6 | { 7 | public: 8 | Alarm(); 9 | void check(); 10 | bool isAlarmOn(); 11 | 12 | protected: 13 | Sensor m_sensor; 14 | double m_lowPressureThreshold; 15 | double m_highPressureThreshold; 16 | bool m_alarmOn; 17 | }; 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring/include/Sensor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Sensor 4 | { 5 | public: 6 | Sensor(); 7 | double popNextPressurePsiValue(); 8 | }; 9 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring/source/Alarm.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/Alarm.h" 3 | 4 | Alarm::Alarm() : m_sensor(), m_lowPressureThreshold(17), m_highPressureThreshold(21), m_alarmOn(false) 5 | {} 6 | 7 | void Alarm::check() 8 | { 9 | double psiPressureValue = m_sensor.popNextPressurePsiValue(); 10 | 11 | if (psiPressureValue < m_lowPressureThreshold || m_highPressureThreshold < psiPressureValue) 12 | { 13 | m_alarmOn = true; 14 | } 15 | } 16 | 17 | bool Alarm::isAlarmOn() 18 | { 19 | return m_alarmOn; 20 | } 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TirePressureMonitoring/source/Sensor.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/Sensor.h" 3 | 4 | #include 5 | #include 6 | 7 | Sensor::Sensor() 8 | { 9 | srand((unsigned)time(0)); 10 | } 11 | 12 | double Sensor::popNextPressurePsiValue() 13 | { 14 | // placeholder implementation that simulates a real sensor in a real tire 15 | double pressure = 16 + (float)rand()/((float)RAND_MAX/(6)); 16 | return pressure; 17 | } 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TurnTicketDispenser.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TurnTicketDispenser ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser.Test/source/TurnTicketDispenserTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TurnTicketDispenser/include/TicketDispenser.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class TurnTicketDispenserTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_GetTicket(); 15 | 16 | CPPUNIT_TEST_SUITE(TurnTicketDispenserTest); 17 | CPPUNIT_TEST(t_GetTicket); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void TurnTicketDispenserTest::t_GetTicket() 22 | { 23 | } 24 | 25 | CPPUNIT_TEST_SUITE_REGISTRATION(TurnTicketDispenserTest); 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TurnTicketDispenser) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/include/TicketDispenser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TurnTicket.h" 4 | 5 | class TicketDispenser 6 | { 7 | public: 8 | TurnTicket getTurnTicket(); 9 | }; 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/include/TurnNumberSequence.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TurnNumberSequence 4 | { 5 | static int s_turnNumber; 6 | 7 | public: 8 | static int getNextTurnNumber(); 9 | }; 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/include/TurnTicket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TurnTicket 4 | { 5 | int const m_turnNumber; 6 | 7 | public: 8 | TurnTicket(int turnNumber); 9 | 10 | int getTurnNumber(); 11 | }; 12 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/source/TicketDispenser.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TicketDispenser.h" 3 | #include "../include/TurnNumberSequence.h" 4 | 5 | TurnTicket TicketDispenser::getTurnTicket() 6 | { 7 | int newTurnNumber = TurnNumberSequence::getNextTurnNumber(); 8 | return TurnTicket(newTurnNumber); 9 | } 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/source/TurnNumberSequence.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TurnNumberSequence.h" 3 | 4 | int TurnNumberSequence::s_turnNumber = 0; 5 | 6 | int TurnNumberSequence::getNextTurnNumber() 7 | { 8 | return s_turnNumber++; 9 | } 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/Source/TurnTicketDispenser/source/TurnTicket.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TurnTicket.h" 3 | 4 | TurnTicket::TurnTicket(int turnNumber) : m_turnNumber(turnNumber) 5 | {} 6 | 7 | int TurnTicket::getTurnNumber() 8 | { 9 | return m_turnNumber; 10 | } 11 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(Racing-Car-Katas) 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) 5 | 6 | IF(NOT CMAKE_BUILD_TYPE) 7 | SET(CMAKE_BUILD_TYPE Debug) 8 | ENDIF() 9 | 10 | GET_FILENAME_COMPONENT( SOURCE_ROOT . ABSOLUTE ) 11 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SOURCE_ROOT}/../Bin) 12 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SOURCE_ROOT}/../Bin) 13 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SOURCE_ROOT}/../Bin) 14 | 15 | find_package(CppUnit REQUIRED) 16 | include_directories(${CPPUNIT_INCLUDE_DIR}) 17 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 18 | 19 | add_compile_options(--std=c++11) 20 | add_compile_options(-Wall) 21 | add_compile_options(-Werror) 22 | 23 | add_subdirectory(TirePressureMonitoring) 24 | add_subdirectory(TirePressureMonitoring.Test) 25 | add_subdirectory(LeaderBoard) 26 | add_subdirectory(LeaderBoard.Test) 27 | add_subdirectory(TelemetrySystem) 28 | add_subdirectory(TelemetrySystem.Test) 29 | add_subdirectory(TurnTicketDispenser) 30 | add_subdirectory(TurnTicketDispenser.Test) 31 | add_subdirectory(TextConverter) 32 | add_subdirectory(TextConverter.Test) 33 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(LeaderBoard.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} LeaderBoard ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard.Test/source/RaceTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TestData.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class RaceTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_CalculateDriverPoints(); 15 | 16 | CPPUNIT_TEST_SUITE(RaceTest); 17 | CPPUNIT_TEST(t_CalculateDriverPoints); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void RaceTest::t_CalculateDriverPoints() 22 | { 23 | CPPUNIT_ASSERT(25 == TestData::race1.getPoints(TestData::driver1)); 24 | CPPUNIT_ASSERT(18 == TestData::race1.getPoints(TestData::driver2)); 25 | CPPUNIT_ASSERT(15 == TestData::race1.getPoints(TestData::driver3)); 26 | } 27 | 28 | CPPUNIT_TEST_SUITE_REGISTRATION(RaceTest); 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard.Test/source/TestData.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TestData.h" 3 | 4 | Driver TestData::driver1("Nico Rosberg", "DE"); 5 | Driver TestData::driver2("Lewis Hamilton", "UK"); 6 | Driver TestData::driver3("Sebastian Vettel", "DE"); 7 | SelfDrivingCar TestData::driver4("1.3", "Acme"); 8 | 9 | Race TestData::race1("Australian Grand Prix", TestData::CreateDriverList(driver1, driver2, driver3)); 10 | Race TestData::race2("Malaysian Grand Prix", TestData::CreateDriverList(driver3, driver2, driver1)); 11 | Race TestData::race3("Chinese Grand Prix", TestData::CreateDriverList(driver2, driver1, driver3)); 12 | Race TestData::race4("Fictional Grand Prix 1", TestData::CreateDriverList(driver1, driver2, driver4)); 13 | Race TestData::race5("Fictional Grand Prix 2", TestData::CreateDriverList(driver4, driver2, driver1)); 14 | Race TestData::race6("Fictional Grand Prix 3", TestData::CreateDriverList(driver2, driver1, driver4)); 15 | 16 | Leaderboard TestData::sampleLeaderboard1(TestData::CreateRaceList(race1, race2, race3)); 17 | Leaderboard TestData::sampleLeaderboard2(TestData::CreateRaceList(race4, race5, race6)); 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(LeaderBoard) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/include/Driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Driver 6 | { 7 | std::string const m_name; 8 | std::string const m_country; 9 | 10 | public: 11 | Driver(std::string const name, std::string const country); 12 | 13 | std::string getName() const; 14 | 15 | std::string getCountry() const; 16 | 17 | bool operator==(Driver const& other) const; 18 | }; 19 | 20 | namespace std 21 | { 22 | template <> 23 | struct hash 24 | { 25 | std::size_t operator()(Driver const& driver) const 26 | { 27 | std::hash< std::string > const hash; 28 | return hash( driver.getName() ) * 31 + hash( driver.getCountry() ); 29 | } 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/include/LeaderBoard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Race.h" 7 | 8 | class Leaderboard 9 | { 10 | std::list m_races; 11 | 12 | public: 13 | Leaderboard(std::list const& races); 14 | 15 | std::map driverResults(); 16 | 17 | std::list driverRankings(); 18 | }; 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/include/Race.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Driver.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class Race 10 | { 11 | static const int POINTS[]; 12 | 13 | std::string m_name; 14 | std::list m_results; 15 | std::unordered_map m_driverNames; 16 | 17 | public: 18 | Race(std::string const& name, std::list const& drivers); 19 | 20 | int position(Driver const& driver); 21 | 22 | int getPoints(Driver driver); 23 | 24 | std::list getResults(); 25 | 26 | std::string getDriverName(Driver driver); 27 | 28 | std::string toString(); 29 | }; 30 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/include/SelfDrivingCar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Driver.h" 4 | 5 | #include 6 | 7 | class SelfDrivingCar : public Driver 8 | { 9 | std::string m_algorithmVersion; 10 | 11 | public: 12 | SelfDrivingCar(std::string algorithmVersion, std::string company); 13 | 14 | std::string getAlgorithmVersion(); 15 | 16 | void setAlgorithmVersion(std::string algorithmVersion); 17 | }; 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/source/Driver.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Driver.h" 2 | 3 | Driver::Driver(std::string const name, std::string const country) : m_name(name), m_country(country) 4 | {} 5 | 6 | std::string Driver::getName() const 7 | { 8 | return m_name; 9 | } 10 | 11 | std::string Driver::getCountry() const 12 | { 13 | return m_country; 14 | } 15 | 16 | bool Driver::operator==(Driver const& other) const 17 | { 18 | if (this == &other) 19 | { 20 | return true; 21 | } 22 | return (m_name.compare(other.m_name) == 0 && m_country.compare(other.m_country) == 0); 23 | } 24 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/LeaderBoard/source/SelfDrivingCar.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/SelfDrivingCar.h" 3 | 4 | SelfDrivingCar::SelfDrivingCar(std::string algorithmVersion, std::string company) : Driver(algorithmVersion, company), m_algorithmVersion( algorithmVersion ) 5 | {} 6 | 7 | std::string SelfDrivingCar::getAlgorithmVersion() 8 | { 9 | return m_algorithmVersion; 10 | } 11 | 12 | void SelfDrivingCar::setAlgorithmVersion(std::string algorithmVersion) 13 | { 14 | m_algorithmVersion = algorithmVersion; 15 | } 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TelemetrySystem.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TelemetrySystem ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem.Test/source/TelemetryDiagnosticControlsTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TelemetrySystem/include/TelemetryClient.h" 3 | #include "TelemetrySystem/include/TelemetryDiagnosticControls.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class TelemetryDiagnosticControlsTest : public CppUnit::TestFixture 10 | { 11 | public: 12 | virtual void setUp() {} 13 | virtual void tearDown() {} 14 | 15 | void t_SendDiagnosticMessageAndReceiveStatusResponse(); 16 | 17 | CPPUNIT_TEST_SUITE(TelemetryDiagnosticControlsTest); 18 | CPPUNIT_TEST(t_SendDiagnosticMessageAndReceiveStatusResponse); 19 | CPPUNIT_TEST_SUITE_END(); 20 | }; 21 | 22 | void TelemetryDiagnosticControlsTest::t_SendDiagnosticMessageAndReceiveStatusResponse() 23 | { 24 | TelemetryDiagnosticControls controls; 25 | controls.checkTransmission(); 26 | CPPUNIT_ASSERT(!controls.getDiagnosticInfo().empty()); 27 | } 28 | 29 | CPPUNIT_TEST_SUITE_REGISTRATION(TelemetryDiagnosticControlsTest); 30 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TelemetrySystem) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem/include/TelemetryClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class TelemetryClient 7 | { 8 | bool m_onlineStatus; 9 | std::string m_diagnosticMessageResult; 10 | std::seed_seq m_seed; 11 | std::mt19937 m_generator; 12 | 13 | public: 14 | static std::string const DIAGNOSTIC_MESSAGE; 15 | 16 | TelemetryClient(); 17 | 18 | bool getOnlineStatus(); 19 | 20 | void connect(std::string const& telemetryServerConnectionString); 21 | 22 | void disconnect(); 23 | 24 | void send(std::string const& message); 25 | 26 | std::string receive(); 27 | }; 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem/include/TelemetryDiagnosticControls.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TelemetryClient.h" 4 | 5 | #include 6 | 7 | class TelemetryDiagnosticControls 8 | { 9 | std::string m_diagnosticChannelConnectionString; 10 | TelemetryClient m_telemetryClient; 11 | std::string m_diagnosticInfo; 12 | 13 | public: 14 | TelemetryDiagnosticControls(); 15 | 16 | std::string getDiagnosticInfo(); 17 | 18 | void setDiagnosticInfo(std::string const& diagnosticInfo); 19 | 20 | void checkTransmission(); 21 | }; 22 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TelemetrySystem/source/TelemetryDiagnosticControls.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TelemetryDiagnosticControls.h" 3 | 4 | #include 5 | 6 | TelemetryDiagnosticControls::TelemetryDiagnosticControls() : 7 | m_diagnosticChannelConnectionString( "*111#" ) 8 | ,m_telemetryClient() 9 | ,m_diagnosticInfo() 10 | {} 11 | 12 | std::string TelemetryDiagnosticControls::getDiagnosticInfo() 13 | { 14 | return m_diagnosticInfo; 15 | } 16 | 17 | void TelemetryDiagnosticControls::setDiagnosticInfo(std::string const& diagnosticInfo) 18 | { 19 | m_diagnosticInfo = diagnosticInfo; 20 | } 21 | 22 | void TelemetryDiagnosticControls::checkTransmission() 23 | { 24 | m_diagnosticInfo = ""; 25 | 26 | m_telemetryClient.disconnect(); 27 | 28 | int retryLeft = 3; 29 | while (m_telemetryClient.getOnlineStatus() == false && retryLeft > 0) 30 | { 31 | m_telemetryClient.connect(m_diagnosticChannelConnectionString); 32 | retryLeft -= 1; 33 | } 34 | 35 | if(m_telemetryClient.getOnlineStatus() == false) 36 | { 37 | throw std::invalid_argument("Unable to connect"); 38 | } 39 | 40 | m_telemetryClient.send(TelemetryClient::DIAGNOSTIC_MESSAGE); 41 | m_diagnosticInfo = m_telemetryClient.receive(); 42 | } 43 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TextConverter.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TextConverter ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter.Test/source/HtmlPagesConverterTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TextConverter/include/HtmlPagesConverter.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class HtmlPagesConverterTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_foo(); 15 | 16 | CPPUNIT_TEST_SUITE(HtmlPagesConverterTest); 17 | CPPUNIT_TEST(t_foo); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void HtmlPagesConverterTest::t_foo() 22 | { 23 | HtmlPagesConverter converter("foo"); 24 | CPPUNIT_ASSERT( std::string("fixme").compare( converter.getFilename() ) == 0 ); 25 | } 26 | 27 | CPPUNIT_TEST_SUITE_REGISTRATION(HtmlPagesConverterTest); 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter.Test/source/HtmlTextConverterTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TextConverter/include/HtmlTextConverter.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class HtmlTextConverterTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_foo(); 15 | 16 | CPPUNIT_TEST_SUITE(HtmlTextConverterTest); 17 | CPPUNIT_TEST(t_foo); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void HtmlTextConverterTest::t_foo() 22 | { 23 | HtmlTextConverter converter("foo"); 24 | CPPUNIT_ASSERT( std::string("fixme").compare( converter.getFilename() ) == 0 ); 25 | } 26 | 27 | CPPUNIT_TEST_SUITE_REGISTRATION(HtmlTextConverterTest); 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TextConverter) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter/include/HtmlPagesConverter.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class HtmlPagesConverter 6 | { 7 | std::string m_filename; 8 | std::vector m_breaks; 9 | 10 | public: 11 | HtmlPagesConverter(std::string const& filename); 12 | 13 | std::string getHtmlPage(int page); 14 | 15 | std::string getFilename(); 16 | }; 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter/include/HtmlTextConverter.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class HtmlTextConverter 6 | { 7 | std::string m_fullFilenameWithPath; 8 | 9 | public: 10 | HtmlTextConverter(std::string const& fullFilenameWithPath); 11 | 12 | std::string convertToHtml(); 13 | 14 | std::string getFilename(); 15 | }; 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter/include/StringEscapeUtils.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class StringEscapeUtils 6 | { 7 | public: 8 | static std::string escapeHtml(std::string const& input) 9 | { 10 | std::string output = input; 11 | output = std::regex_replace(output, std::regex("[&]"), "&"); 12 | output = std::regex_replace(output, std::regex("[<]"), "<"); 13 | output = std::regex_replace(output, std::regex("[>]"), ">"); 14 | output = std::regex_replace(output, std::regex("[\"]"), """); 15 | output = std::regex_replace(output, std::regex("[']"), """); 16 | return output; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TextConverter/source/HtmlTextConverter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/HtmlTextConverter.h" 3 | #include "../include/StringEscapeUtils.h" 4 | 5 | HtmlTextConverter::HtmlTextConverter(std::string const& fullFilenameWithPath) : m_fullFilenameWithPath(fullFilenameWithPath) 6 | {} 7 | 8 | std::string HtmlTextConverter::convertToHtml() 9 | { 10 | std::ifstream reader(m_fullFilenameWithPath); 11 | 12 | std::string line; 13 | std::string html; 14 | while (std::getline(reader,line)) 15 | { 16 | html += StringEscapeUtils::escapeHtml(line); 17 | html += "
    "; 18 | } 19 | return html; 20 | } 21 | 22 | std::string HtmlTextConverter::getFilename() 23 | { 24 | return m_fullFilenameWithPath; 25 | } 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TirePressureMonitoring.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TirePressureMonitoring ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring.Test/source/AlarmTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TirePressureMonitoring/include/Alarm.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | ///< \todo Remove/Clean-up before final commit 9 | 10 | class AlarmTest : public CppUnit::TestFixture 11 | { 12 | public: 13 | virtual void setUp() {} 14 | virtual void tearDown() {} 15 | 16 | void t_FirstTest(); 17 | 18 | CPPUNIT_TEST_SUITE(AlarmTest); 19 | CPPUNIT_TEST(t_FirstTest); 20 | CPPUNIT_TEST_SUITE_END(); 21 | }; 22 | 23 | void AlarmTest::t_FirstTest() 24 | { 25 | CPPUNIT_ASSERT(false); 26 | } 27 | 28 | CPPUNIT_TEST_SUITE_REGISTRATION(AlarmTest); 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TirePressureMonitoring) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring/include/Alarm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sensor.h" 4 | 5 | class Alarm 6 | { 7 | public: 8 | Alarm(); 9 | void check(); 10 | bool isAlarmOn(); 11 | 12 | protected: 13 | Sensor m_sensor; 14 | double m_lowPressureThreshold; 15 | double m_highPressureThreshold; 16 | bool m_alarmOn; 17 | }; 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring/include/Sensor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Sensor 4 | { 5 | public: 6 | Sensor(); 7 | double popNextPressurePsiValue(); 8 | }; 9 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring/source/Alarm.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/Alarm.h" 3 | 4 | Alarm::Alarm() : m_sensor(), m_lowPressureThreshold(17), m_highPressureThreshold(21), m_alarmOn(false) 5 | {} 6 | 7 | void Alarm::check() 8 | { 9 | double psiPressureValue = m_sensor.popNextPressurePsiValue(); 10 | 11 | if (psiPressureValue < m_lowPressureThreshold || m_highPressureThreshold < psiPressureValue) 12 | { 13 | m_alarmOn = true; 14 | } 15 | } 16 | 17 | bool Alarm::isAlarmOn() 18 | { 19 | return m_alarmOn; 20 | } 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TirePressureMonitoring/source/Sensor.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/Sensor.h" 3 | 4 | #include 5 | #include 6 | 7 | Sensor::Sensor() 8 | { 9 | srand((unsigned)time(0)); 10 | } 11 | 12 | double Sensor::popNextPressurePsiValue() 13 | { 14 | // placeholder implementation that simulates a real sensor in a real tire 15 | double pressure = 16 + (float)rand()/((float)RAND_MAX/(6)); 16 | return pressure; 17 | } 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TurnTicketDispenser.Test) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} TurnTicketDispenser ${CPPUNIT_LIBRARIES}) 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser.Test/source/TurnTicketDispenserTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TurnTicketDispenser/include/TicketDispenser.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class TurnTicketDispenserTest : public CppUnit::TestFixture 9 | { 10 | public: 11 | virtual void setUp() {} 12 | virtual void tearDown() {} 13 | 14 | void t_GetTicket(); 15 | 16 | CPPUNIT_TEST_SUITE(TurnTicketDispenserTest); 17 | CPPUNIT_TEST(t_GetTicket); 18 | CPPUNIT_TEST_SUITE_END(); 19 | }; 20 | 21 | void TurnTicketDispenserTest::t_GetTicket() 22 | { 23 | } 24 | 25 | CPPUNIT_TEST_SUITE_REGISTRATION(TurnTicketDispenserTest); 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser.Test/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char **argv) { 13 | CPPUNIT_NS::TestResult testresult; 14 | CPPUNIT_NS::TestResultCollector collectedresults; 15 | testresult.addListener(&collectedresults); 16 | 17 | CPPUNIT_NS::BriefTestProgressListener progress; 18 | testresult.addListener(&progress); 19 | 20 | CPPUNIT_NS::TestRunner testrunner; 21 | testrunner.addTest( 22 | CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 23 | testrunner.run(testresult); 24 | 25 | CPPUNIT_NS::CompilerOutputter(&collectedresults, std::cerr).write(); 26 | 27 | return !collectedresults.wasSuccessful(); 28 | } 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(TurnTicketDispenser) 3 | 4 | aux_source_directory(source PROJECT_SOURCE) 5 | file(GLOB PROJECT_INCLUDES "include/*.h") 6 | 7 | add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/include/TicketDispenser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TurnTicket.h" 4 | 5 | class TicketDispenser 6 | { 7 | public: 8 | TurnTicket getTurnTicket(); 9 | }; 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/include/TurnNumberSequence.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TurnNumberSequence 4 | { 5 | static int s_turnNumber; 6 | 7 | public: 8 | static int getNextTurnNumber(); 9 | }; 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/include/TurnTicket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TurnTicket 4 | { 5 | int const m_turnNumber; 6 | 7 | public: 8 | TurnTicket(int turnNumber); 9 | 10 | int getTurnNumber(); 11 | }; 12 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/source/TicketDispenser.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TicketDispenser.h" 3 | #include "../include/TurnNumberSequence.h" 4 | 5 | TurnTicket TicketDispenser::getTurnTicket() 6 | { 7 | int newTurnNumber = TurnNumberSequence::getNextTurnNumber(); 8 | return TurnTicket(newTurnNumber); 9 | } 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/source/TurnNumberSequence.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TurnNumberSequence.h" 3 | 4 | int TurnNumberSequence::s_turnNumber = 0; 5 | 6 | int TurnNumberSequence::getNextTurnNumber() 7 | { 8 | return s_turnNumber++; 9 | } 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/cmake_version/Source/TurnTicketDispenser/source/TurnTicket.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/TurnTicket.h" 3 | 4 | TurnTicket::TurnTicket(int turnNumber) : m_turnNumber(turnNumber) 5 | {} 6 | 7 | int TurnTicket::getTurnNumber() 8 | { 9 | return m_turnNumber; 10 | } 11 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/HtmlTextConverter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "HtmlTextConverter.hpp" 3 | #include "StreamConverter.hpp" 4 | #include "StringEscapeUtils.hpp" 5 | 6 | #include 7 | 8 | HtmlTextConverter::HtmlTextConverter(std::string& filename) : 9 | m_filename(filename) 10 | {} 11 | 12 | std::string HtmlTextConverter::convertToHtml() 13 | { 14 | std::ifstream reader(m_filename); 15 | StreamConverter converter(reader); 16 | return converter.convertToHtml(); 17 | } 18 | 19 | std::string HtmlTextConverter::getFilename() 20 | { 21 | return m_filename; 22 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/HtmlTextConverter.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class HtmlTextConverter 6 | { 7 | std::string m_filename; 8 | 9 | public: 10 | HtmlTextConverter(std::string& filename); 11 | 12 | std::string convertToHtml(); 13 | 14 | std::string getFilename(); 15 | }; 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/HtmlTextConverter.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "HtmlTextConverter.hpp" 2 | #include 3 | 4 | using namespace ::testing; 5 | 6 | TEST(HtmlTextConverter, can_open_a_file) 7 | { 8 | std::string filename("foo.txt"); 9 | HtmlTextConverter converter(filename); 10 | ASSERT_EQ(filename, converter.getFilename()); 11 | ASSERT_EQ("", converter.convertToHtml()); 12 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/StreamConverter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "StreamConverter.hpp" 3 | #include "StringEscapeUtils.hpp" 4 | 5 | #include 6 | 7 | StreamConverter::StreamConverter(std::istream& textStream) : 8 | m_textStream(textStream) 9 | {} 10 | 11 | std::string StreamConverter::convertToHtml() 12 | { 13 | std::string line; 14 | std::string html; 15 | while (std::getline(m_textStream,line)) 16 | { 17 | html += StringEscapeUtils::escapeHtml(line); 18 | html += "
    "; 19 | } 20 | return html; 21 | } 22 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/StreamConverter.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class StreamConverter 6 | { 7 | std::istream& m_textStream; 8 | 9 | public: 10 | StreamConverter(std::istream& textStream); 11 | 12 | std::string convertToHtml(); 13 | 14 | }; 15 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/StreamConverter.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "StreamConverter.hpp" 2 | #include 3 | 4 | #include 5 | 6 | using namespace ::testing; 7 | 8 | TEST(StreamConverter, newlines_become_br) 9 | { 10 | std::stringstream reader("hej\npå\ndej\n"); 11 | 12 | StreamConverter converter(reader); 13 | 14 | std::string htmlString = converter.convertToHtml(); 15 | 16 | ASSERT_STREQ("hej

    dej
    ", htmlString.c_str()); 17 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/StringEscapeUtils.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | class StringEscapeUtils 5 | { 6 | public: 7 | static std::string escapeHtml(std::string const& input) 8 | { 9 | std::string output = input; 10 | output = replaceAll(output, "&", "&"); 11 | output = replaceAll(output, "<", "<"); 12 | output = replaceAll(output, ">", ">"); 13 | output = replaceAll(output, "\"", """); 14 | output = replaceAll(output, "'", """); 15 | return output; 16 | } 17 | 18 | static std::string replaceAll(std::string str, const std::string& from, const std::string& to) 19 | { 20 | size_t start_pos = 0; 21 | while((start_pos = str.find(from, start_pos)) != std::string::npos) 22 | { 23 | str.replace(start_pos, from.length(), to); 24 | start_pos += to.length(); // Handles case where 'to' is a substring of 'from' 25 | } 26 | return str; 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/foo.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/racing-car-katas/exercises/Cpp/gmock_version/textconverter/foo.txt -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/instructions.txt: -------------------------------------------------------------------------------- 1 | 2 | Write more unit tests for the UnicodeFileToHtmlTextConverter class. 3 | 4 | The HtmlTextConverter class is designed to reformat a 5 | plain text file for display in a browser. 6 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgtest_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/textconverter/test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/racing-car-katas/exercises/Cpp/gmock_version/textconverter/test -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/Alarm.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Alarm.hpp" 3 | #include "Sensor.hpp" 4 | 5 | Alarm::Alarm(Sensor *sensor) : m_sensor(sensor), 6 | m_lowPressureThreshold(17), 7 | m_highPressureThreshold(21), 8 | m_alarmOn(false) 9 | {} 10 | 11 | void Alarm::check() 12 | { 13 | double psiPressureValue = m_sensor->popNextPressurePsiValue(); 14 | 15 | if (psiPressureValue < m_lowPressureThreshold || m_highPressureThreshold < psiPressureValue) 16 | { 17 | m_alarmOn = true; 18 | } 19 | } 20 | 21 | bool Alarm::isAlarmOn() 22 | { 23 | return m_alarmOn; 24 | } 25 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/Alarm.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Sensor.hpp" 3 | 4 | class Alarm 5 | { 6 | public: 7 | Alarm(Sensor *sensor); 8 | void check(); 9 | bool isAlarmOn(); 10 | 11 | protected: 12 | Sensor *m_sensor; 13 | double m_lowPressureThreshold; 14 | double m_highPressureThreshold; 15 | bool m_alarmOn; 16 | }; 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/Alarm.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "Alarm.hpp" 2 | #include "StubSensor.hpp" 3 | #include 4 | 5 | using namespace ::testing; 6 | 7 | namespace { 8 | 9 | TEST(Alarm, Foobar) 10 | { 11 | StubSensor stubSensor; 12 | EXPECT_CALL(stubSensor, popNextPressurePsiValue()) 13 | .WillOnce(Return(16)); 14 | 15 | Alarm alarm(&stubSensor); 16 | alarm.check(); 17 | 18 | ASSERT_THAT(alarm.isAlarmOn(), Eq(true)); 19 | 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/PressureSensor.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "PressureSensor.hpp" 3 | 4 | #include 5 | #include 6 | 7 | PressureSensor::PressureSensor() 8 | { 9 | srand((unsigned)time(0)); 10 | } 11 | 12 | double PressureSensor::popNextPressurePsiValue() 13 | { 14 | // placeholder implementation that simulates a real sensor 15 | // in a real tire 16 | double pressure = 16 + (float)rand()/((float)RAND_MAX/(6)); 17 | return pressure; 18 | } 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/PressureSensor.hpp: -------------------------------------------------------------------------------- 1 | #include "Sensor.hpp" 2 | 3 | class PressureSensor : public Sensor 4 | { 5 | public: 6 | PressureSensor(); 7 | double popNextPressurePsiValue(); 8 | }; -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/Sensor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SENSOR_INCLUDED 2 | #define SENSOR_INCLUDED 3 | 4 | class Sensor 5 | { 6 | public: 7 | virtual double popNextPressurePsiValue() = 0; 8 | }; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/StubSensor.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Sensor.hpp" 3 | 4 | class StubSensor : public Sensor { 5 | public: 6 | MOCK_METHOD0(popNextPressurePsiValue, double()); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgmock -lgmock_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pragmateam/coding-dojo/8c5e001ab420b412cdefbb52e55e0b519ac59b8b/racing-car-katas/exercises/Cpp/gmock_version/tyrepressure/test -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Driver.cpp: -------------------------------------------------------------------------------- 1 | #include "Driver.hpp" 2 | 3 | Driver::Driver(std::string const name, std::string const country) : m_name(name), m_country(country) 4 | {} 5 | 6 | std::string Driver::getName() const 7 | { 8 | return m_name; 9 | } 10 | 11 | std::string Driver::getCountry() const 12 | { 13 | return m_country; 14 | } 15 | 16 | bool Driver::operator==(Driver const& other) const 17 | { 18 | if (this == &other) 19 | { 20 | return true; 21 | } 22 | return (m_name.compare(other.m_name) == 0 && m_country.compare(other.m_country) == 0); 23 | } 24 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Driver.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DRIVER_INCLUDED 2 | #define DRIVER_INCLUDED 3 | 4 | #include 5 | 6 | class Driver 7 | { 8 | std::string const m_name; 9 | std::string const m_country; 10 | 11 | public: 12 | Driver(std::string const name, std::string const country); 13 | 14 | std::string getName() const; 15 | 16 | std::string getCountry() const; 17 | 18 | bool operator==(Driver const& other) const; 19 | }; 20 | 21 | namespace std 22 | { 23 | template <> 24 | struct hash 25 | { 26 | std::size_t operator()(Driver const& driver) const 27 | { 28 | std::hash< std::string > const hash; 29 | return hash( driver.getName() ) * 31 + hash( driver.getCountry() ); 30 | } 31 | }; 32 | } 33 | 34 | #endif -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Leaderboard.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Leaderboard.hpp" 3 | 4 | #include 5 | 6 | Leaderboard::Leaderboard(std::list const& races) : m_races(races) 7 | {} 8 | 9 | std::map Leaderboard::driverResults() 10 | { 11 | std::map results; 12 | for (Race& race : m_races) 13 | { 14 | for (Driver& driver : race.getResults()) 15 | { 16 | std::string driverName = race.getDriverName(driver); 17 | int points = race.getPoints(driver); 18 | if (results.end() != results.find(driverName)) 19 | { 20 | results[driverName] += points; 21 | } else 22 | { 23 | results[driverName] = points; 24 | } 25 | } 26 | } 27 | return results; 28 | } 29 | 30 | std::list Leaderboard::driverRankings() 31 | { 32 | std::map results = driverResults(); 33 | std::list resultsList; 34 | for(std::map::value_type const& v : results) 35 | { 36 | resultsList.push_back( v.first ); 37 | } 38 | resultsList.sort([&results](std::string const& driverName1, std::string const& driverName2) 39 | { 40 | return results[driverName1] > results[driverName2]; 41 | }); 42 | return resultsList; 43 | } 44 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Leaderboard.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "Race.hpp" 6 | 7 | class Leaderboard 8 | { 9 | std::list m_races; 10 | 11 | public: 12 | Leaderboard(std::list const& races); 13 | 14 | std::map driverResults(); 15 | 16 | std::list driverRankings(); 17 | }; 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Race.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Race.hpp" 3 | #include "SelfDrivingCar.hpp" 4 | 5 | #include 6 | 7 | const int Race::POINTS[] = { 25, 18, 15 }; 8 | 9 | Race::Race(std::string const& name, std::list const& drivers) : m_name(name), m_results(drivers) 10 | { 11 | for (Driver& driver : m_results) 12 | { 13 | std::string driverName = driver.getName(); 14 | if (typeid(driver) == typeid(SelfDrivingCar)) 15 | { 16 | driverName = "Self Driving Car - " + driver.getCountry() + " (" + (static_cast(driver)).getAlgorithmVersion() + ")"; 17 | } 18 | m_driverNames[driver] = driverName; 19 | } 20 | } 21 | 22 | int Race::position(Driver const& driver) 23 | { 24 | int count = 0; 25 | for (Driver& d : m_results) 26 | { 27 | if ( d == driver ) 28 | { 29 | break; 30 | } 31 | ++count; 32 | } 33 | return count; 34 | } 35 | 36 | int Race::getPoints(Driver driver) 37 | { 38 | return POINTS[position(driver)]; 39 | } 40 | 41 | std::list Race::getResults() 42 | { 43 | return m_results; 44 | } 45 | 46 | std::string Race::getDriverName(Driver driver) 47 | { 48 | return m_driverNames[driver]; 49 | } 50 | 51 | std::string Race::toString() 52 | { 53 | return m_name; 54 | } 55 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Race.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RACE_INCLUDED 2 | #define RACE_INCLUDED 3 | 4 | #include "Driver.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | class Race 11 | { 12 | static const int POINTS[]; 13 | 14 | std::string m_name; 15 | std::list m_results; 16 | std::unordered_map m_driverNames; 17 | 18 | public: 19 | Race(std::string const& name, std::list const& drivers); 20 | 21 | int position(Driver const& driver); 22 | 23 | int getPoints(Driver driver); 24 | 25 | std::list getResults(); 26 | 27 | std::string getDriverName(Driver driver); 28 | 29 | std::string toString(); 30 | }; 31 | 32 | #endif -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/Race.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "TestData.hpp" 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | using namespace ::testing; 8 | 9 | TEST(Race, CalculateDriverPoints) 10 | { 11 | ASSERT_EQ(25, TestData::race1.getPoints(TestData::driver1)); 12 | ASSERT_EQ(18, TestData::race1.getPoints(TestData::driver2)); 13 | ASSERT_EQ(15, TestData::race1.getPoints(TestData::driver3)); 14 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/SelfDrivingCar.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "SelfDrivingCar.hpp" 3 | 4 | SelfDrivingCar::SelfDrivingCar(std::string algorithmVersion, 5 | std::string company) : Driver(algorithmVersion, company), m_algorithmVersion( algorithmVersion ) 6 | {} 7 | 8 | std::string SelfDrivingCar::getAlgorithmVersion() 9 | { 10 | return m_algorithmVersion; 11 | } 12 | 13 | void SelfDrivingCar::setAlgorithmVersion(std::string algorithmVersion) 14 | { 15 | m_algorithmVersion = algorithmVersion; 16 | } 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/SelfDrivingCar.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Driver.hpp" 3 | 4 | #include 5 | 6 | class SelfDrivingCar : public Driver 7 | { 8 | std::string m_algorithmVersion; 9 | 10 | public: 11 | SelfDrivingCar(std::string algorithmVersion, std::string company); 12 | 13 | std::string getAlgorithmVersion(); 14 | 15 | void setAlgorithmVersion(std::string algorithmVersion); 16 | }; 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/TestData.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TestData.hpp" 3 | 4 | Driver TestData::driver1("Nico Rosberg", "DE"); 5 | Driver TestData::driver2("Lewis Hamilton", "UK"); 6 | Driver TestData::driver3("Sebastian Vettel", "DE"); 7 | SelfDrivingCar TestData::driver4("1.3", "Acme"); 8 | 9 | Race TestData::race1("Australian Grand Prix", TestData::CreateDriverList(driver1, driver2, driver3)); 10 | Race TestData::race2("Malaysian Grand Prix", TestData::CreateDriverList(driver3, driver2, driver1)); 11 | Race TestData::race3("Chinese Grand Prix", TestData::CreateDriverList(driver2, driver1, driver3)); 12 | Race TestData::race4("Fictional Grand Prix 1", TestData::CreateDriverList(driver1, driver2, driver4)); 13 | Race TestData::race5("Fictional Grand Prix 2", TestData::CreateDriverList(driver4, driver2, driver1)); 14 | Race TestData::race6("Fictional Grand Prix 3", TestData::CreateDriverList(driver2, driver1, driver4)); 15 | 16 | Leaderboard TestData::sampleLeaderboard1(TestData::CreateRaceList(race1, race2, race3)); 17 | Leaderboard TestData::sampleLeaderboard2(TestData::CreateRaceList(race4, race5, race6)); 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/TestData.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Driver.hpp" 3 | #include "Race.hpp" 4 | #include "SelfDrivingCar.hpp" 5 | #include "Leaderboard.hpp" 6 | 7 | class TestData 8 | { 9 | public: 10 | static Driver driver1; 11 | static Driver driver2; 12 | static Driver driver3; 13 | static SelfDrivingCar driver4; 14 | 15 | static Race race1; 16 | static Race race2; 17 | static Race race3; 18 | static Race race4; 19 | static Race race5; 20 | static Race race6; 21 | 22 | static Leaderboard sampleLeaderboard1; 23 | static Leaderboard sampleLeaderboard2; 24 | 25 | static std::list< Driver > CreateDriverList( Driver a, Driver b, Driver c ) 26 | { 27 | std::list< Driver > l; 28 | l.push_back(a); 29 | l.push_back(b); 30 | l.push_back(c); 31 | return std::move(l); 32 | } 33 | 34 | static std::list< Race > CreateRaceList( Race a, Race b, Race c ) 35 | { 36 | std::list< Race > l; 37 | l.push_back(a); 38 | l.push_back(b); 39 | l.push_back(c); 40 | return std::move(l); 41 | } 42 | 43 | static std::list< Race > CreateRaceList( Race a, Race b ) 44 | { 45 | std::list< Race > l; 46 | l.push_back(a); 47 | l.push_back(b); 48 | return std::move(l); 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/leaderboard/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgtest_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/telemetrydiagnostics/Telemetry.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TelemetryDiagnosticControls.hpp" 3 | #include 4 | 5 | using namespace ::testing; 6 | 7 | TEST(TelemetryDiagnosticControls, SendDiagnosticMessageAndReceiveStatusResponse) 8 | { 9 | TelemetryDiagnosticControls controls; 10 | controls.checkTransmission(); 11 | ASSERT_EQ(false, controls.getDiagnosticInfo().empty()); 12 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/telemetrydiagnostics/TelemetryClient.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class TelemetryClient 6 | { 7 | bool m_onlineStatus; 8 | std::string m_diagnosticMessageResult; 9 | std::seed_seq m_seed; 10 | std::mt19937 m_generator; 11 | 12 | public: 13 | static std::string const DIAGNOSTIC_MESSAGE; 14 | 15 | TelemetryClient(); 16 | 17 | bool getOnlineStatus(); 18 | 19 | void connect(std::string const& telemetryServerConnectionString); 20 | 21 | void disconnect(); 22 | 23 | void send(std::string const& message); 24 | 25 | std::string receive(); 26 | }; 27 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/telemetrydiagnostics/TelemetryDiagnosticControls.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TelemetryDiagnosticControls.hpp" 3 | 4 | #include 5 | 6 | TelemetryDiagnosticControls::TelemetryDiagnosticControls() : 7 | m_diagnosticChannelConnectionString( "*111#" ) 8 | ,m_telemetryClient() 9 | ,m_diagnosticInfo() 10 | {} 11 | 12 | std::string TelemetryDiagnosticControls::getDiagnosticInfo() 13 | { 14 | return m_diagnosticInfo; 15 | } 16 | 17 | void TelemetryDiagnosticControls::setDiagnosticInfo(std::string const& diagnosticInfo) 18 | { 19 | m_diagnosticInfo = diagnosticInfo; 20 | } 21 | 22 | void TelemetryDiagnosticControls::checkTransmission() 23 | { 24 | m_diagnosticInfo = ""; 25 | 26 | m_telemetryClient.disconnect(); 27 | 28 | int retryLeft = 3; 29 | while (m_telemetryClient.getOnlineStatus() == false && retryLeft > 0) 30 | { 31 | m_telemetryClient.connect(m_diagnosticChannelConnectionString); 32 | retryLeft -= 1; 33 | } 34 | 35 | if(m_telemetryClient.getOnlineStatus() == false) 36 | { 37 | throw std::invalid_argument("Unable to connect"); 38 | } 39 | 40 | m_telemetryClient.send(TelemetryClient::DIAGNOSTIC_MESSAGE); 41 | m_diagnosticInfo = m_telemetryClient.receive(); 42 | } 43 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/telemetrydiagnostics/TelemetryDiagnosticControls.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TelemetryClient.hpp" 3 | 4 | #include 5 | 6 | class TelemetryDiagnosticControls 7 | { 8 | std::string m_diagnosticChannelConnectionString; 9 | TelemetryClient m_telemetryClient; 10 | std::string m_diagnosticInfo; 11 | 12 | public: 13 | TelemetryDiagnosticControls(); 14 | 15 | std::string getDiagnosticInfo(); 16 | 17 | void setDiagnosticInfo(std::string const& diagnosticInfo); 18 | 19 | void checkTransmission(); 20 | }; 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/telemetrydiagnostics/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgtest_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/textconverter/HtmlTextConverter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "HtmlTextConverter.hpp" 3 | #include "StringEscapeUtils.hpp" 4 | 5 | HtmlTextConverter::HtmlTextConverter(std::string const& fullFilenameWithPath) : m_fullFilenameWithPath(fullFilenameWithPath) 6 | {} 7 | 8 | std::string HtmlTextConverter::convertToHtml() 9 | { 10 | std::ifstream reader(m_fullFilenameWithPath); 11 | 12 | std::string line; 13 | std::string html; 14 | while (std::getline(reader,line)) 15 | { 16 | html += StringEscapeUtils::escapeHtml(line); 17 | html += "
    "; 18 | } 19 | return html; 20 | } 21 | 22 | std::string HtmlTextConverter::getFilename() 23 | { 24 | return m_fullFilenameWithPath; 25 | } 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/textconverter/HtmlTextConverter.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class HtmlTextConverter 6 | { 7 | std::string m_fullFilenameWithPath; 8 | 9 | public: 10 | HtmlTextConverter(std::string const& fullFilenameWithPath); 11 | 12 | std::string convertToHtml(); 13 | 14 | std::string getFilename(); 15 | }; 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/textconverter/HtmlTextConverter.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "HtmlTextConverter.hpp" 2 | #include 3 | 4 | using namespace ::testing; 5 | 6 | TEST(HtmlTextConverter, foo) 7 | { 8 | HtmlTextConverter converter("foo"); 9 | ASSERT_EQ(std::string("fixme"), converter.getFilename()); 10 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/textconverter/StringEscapeUtils.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | class StringEscapeUtils 5 | { 6 | public: 7 | static std::string escapeHtml(std::string const& input) 8 | { 9 | std::string output = input; 10 | output = replaceAll(output, "&", "&"); 11 | output = replaceAll(output, "<", "<"); 12 | output = replaceAll(output, ">", ">"); 13 | output = replaceAll(output, "\"", """); 14 | output = replaceAll(output, "'", """); 15 | return output; 16 | } 17 | 18 | static std::string replaceAll(std::string str, const std::string& from, const std::string& to) 19 | { 20 | size_t start_pos = 0; 21 | while((start_pos = str.find(from, start_pos)) != std::string::npos) 22 | { 23 | str.replace(start_pos, from.length(), to); 24 | start_pos += to.length(); // Handles case where 'to' is a substring of 'from' 25 | } 26 | return str; 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/textconverter/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgtest_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TicketDispenser.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TicketDispenser.hpp" 3 | #include "TurnNumberSequence.hpp" 4 | 5 | TurnTicket TicketDispenser::getTurnTicket() 6 | { 7 | int newTurnNumber = TurnNumberSequence::getNextTurnNumber(); 8 | return TurnTicket(newTurnNumber); 9 | } 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TicketDispenser.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TurnTicket.hpp" 3 | 4 | class TicketDispenser 5 | { 6 | public: 7 | TurnTicket getTurnTicket(); 8 | }; 9 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TicketDispenser.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "TicketDispenser.hpp" 2 | #include 3 | 4 | using namespace ::testing; 5 | 6 | TEST(TurnTicketDispenser, getTicket) 7 | { 8 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TurnNumberSequence.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TurnNumberSequence.hpp" 3 | 4 | int TurnNumberSequence::s_turnNumber = 0; 5 | 6 | int TurnNumberSequence::getNextTurnNumber() 7 | { 8 | return s_turnNumber++; 9 | } 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TurnNumberSequence.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | class TurnNumberSequence 4 | { 5 | static int s_turnNumber; 6 | 7 | public: 8 | static int getNextTurnNumber(); 9 | }; 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TurnTicket.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TurnTicket.hpp" 3 | 4 | TurnTicket::TurnTicket(int turnNumber) : m_turnNumber(turnNumber) 5 | {} 6 | 7 | int TurnTicket::getTurnNumber() 8 | { 9 | return m_turnNumber; 10 | } 11 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/TurnTicket.hpp: -------------------------------------------------------------------------------- 1 | 2 | class TurnTicket 3 | { 4 | int const m_turnNumber; 5 | 6 | public: 7 | TurnTicket(int turnNumber); 8 | 9 | int getTurnNumber(); 10 | }; 11 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/turnticket/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgtest_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/tyrepressure/Alarm.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Alarm.hpp" 3 | 4 | Alarm::Alarm() : m_sensor(), m_lowPressureThreshold(17), m_highPressureThreshold(21), m_alarmOn(false) 5 | {} 6 | 7 | void Alarm::check() 8 | { 9 | double psiPressureValue = m_sensor.popNextPressurePsiValue(); 10 | 11 | if (psiPressureValue < m_lowPressureThreshold || m_highPressureThreshold < psiPressureValue) 12 | { 13 | m_alarmOn = true; 14 | } 15 | } 16 | 17 | bool Alarm::isAlarmOn() 18 | { 19 | return m_alarmOn; 20 | } 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/tyrepressure/Alarm.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Sensor.hpp" 3 | 4 | class Alarm 5 | { 6 | public: 7 | Alarm(); 8 | void check(); 9 | bool isAlarmOn(); 10 | 11 | protected: 12 | Sensor m_sensor; 13 | double m_lowPressureThreshold; 14 | double m_highPressureThreshold; 15 | bool m_alarmOn; 16 | }; 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/tyrepressure/Alarm.tests.cpp: -------------------------------------------------------------------------------- 1 | #include "Alarm.hpp" 2 | #include 3 | 4 | using namespace ::testing; 5 | 6 | TEST(Alarm, Foobar) 7 | { 8 | Alarm *alarm = new Alarm(); 9 | ASSERT_EQ(true, alarm->isAlarmOn()); 10 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/tyrepressure/Sensor.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Sensor.hpp" 3 | 4 | #include 5 | #include 6 | 7 | Sensor::Sensor() 8 | { 9 | srand((unsigned)time(0)); 10 | } 11 | 12 | double Sensor::popNextPressurePsiValue() 13 | { 14 | // placeholder implementation that simulates a real sensor 15 | // in a real tire 16 | double pressure = 16 + (float)rand()/((float)RAND_MAX/(6)); 17 | return pressure; 18 | } 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/tyrepressure/Sensor.hpp: -------------------------------------------------------------------------------- 1 | 2 | class Sensor 3 | { 4 | public: 5 | Sensor(); 6 | double popNextPressurePsiValue(); 7 | }; 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Cpp/gtest_version/tyrepressure/makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS += -I. -std=c++11 -Wall -Wextra -Werror 2 | GTEST_LIBS = -lgtest -lgtest_main -pthread 3 | 4 | HPP_FILES = $(wildcard *.hpp) 5 | COMPILED_HPP_FILES = $(patsubst %.hpp,%.compiled_hpp,$(HPP_FILES)) 6 | CPP_FILES = $(wildcard *.cpp) 7 | 8 | .PHONY: test.output 9 | test.output: test makefile 10 | @./$< --gtest_shuffle 11 | 12 | test: makefile $(CPP_FILES) $(COMPILED_HPP_FILES) 13 | @$(CXX) $(CXXFLAGS) -O $(CPP_FILES) $(GTEST_LIBS) -o $@ 14 | 15 | # This rule ensures header files build in their own right. 16 | # The quality of header files is important because header files 17 | # are #included from other files and thus have a large span 18 | # of influence (unlike .cpp files which are not #included) 19 | 20 | %.compiled_hpp: %.hpp 21 | @$(CXX) -x c++ $(CXXFLAGS) -c -o $@ $< -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | bin/ 3 | .settings/ 4 | .project 5 | .classpath 6 | .checkstyle 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/Leaderboard/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | Leaderboard 5 | Leaderboard 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | junit 10 | junit 11 | 4.9 12 | jar 13 | test 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-compiler-plugin 21 | 3.3 22 | 23 | 1.8 24 | 1.8 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/Leaderboard/src/main/java/tddmicroexercises/leaderboard/Driver.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.leaderboard; 2 | 3 | public class Driver { 4 | 5 | private final String name; 6 | private final String country; 7 | 8 | public Driver(String name, String country) { 9 | this.name = name; 10 | this.country = country; 11 | } 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | public String getCountry() { 18 | return country; 19 | } 20 | 21 | @Override 22 | public int hashCode() { 23 | return name.hashCode() * 31 + country.hashCode(); 24 | } 25 | 26 | @Override 27 | public boolean equals(Object obj) { 28 | if (this == obj) { 29 | return true; 30 | } 31 | if (obj == null || !(obj instanceof Driver)) { 32 | return false; 33 | } 34 | Driver other = (Driver) obj; 35 | return this.name.equals(other.name) && this.country.equals(other.country); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/Leaderboard/src/main/java/tddmicroexercises/leaderboard/SelfDrivingCar.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.leaderboard; 2 | 3 | public class SelfDrivingCar extends Driver { 4 | 5 | private String algorithmVersion; 6 | 7 | public SelfDrivingCar(String algorithmVersion, String company) { 8 | super(algorithmVersion, company); 9 | this.algorithmVersion = algorithmVersion; 10 | } 11 | 12 | public String getAlgorithmVersion() { 13 | return algorithmVersion; 14 | } 15 | 16 | public void setAlgorithmVersion(String algorithmVersion) { 17 | this.algorithmVersion = algorithmVersion; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/Leaderboard/src/test/java/tddmicroexercises/leaderboard/RaceTest.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.leaderboard; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class RaceTest { 7 | 8 | @Test 9 | public void isShouldCalculateDriverPoints() { 10 | // setup 11 | 12 | // act 13 | 14 | // verify 15 | Assert.assertEquals(25, TestData.race1.getPoints(TestData.driver1)); 16 | Assert.assertEquals(18, TestData.race1.getPoints(TestData.driver2)); 17 | Assert.assertEquals(15, TestData.race1.getPoints(TestData.driver3)); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TelemetrySystem/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | TelemetrySystem 5 | TelemetrySystem 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | junit 10 | junit 11 | 4.9 12 | jar 13 | test 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-compiler-plugin 21 | 3.3 22 | 23 | 1.8 24 | 1.8 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TelemetrySystem/src/test/java/tddmicroexercises/telemetrysystem/TelemetryDiagnosticControlsTest.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.telemetrysystem; 2 | 3 | import org.junit.Test; 4 | 5 | public class TelemetryDiagnosticControlsTest 6 | { 7 | 8 | @Test 9 | public void CheckTransmission_should_send_a_diagnostic_message_and_receive_a_status_message_response() 10 | { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TextConverter/src/main/java/tddmicroexercises/textconvertor/HtmlTextConverter.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | 7 | public class HtmlTextConverter 8 | { 9 | private String fullFilenameWithPath; 10 | 11 | public HtmlTextConverter(String fullFilenameWithPath) 12 | { 13 | this.fullFilenameWithPath = fullFilenameWithPath; 14 | } 15 | 16 | public String convertToHtml() throws IOException{ 17 | 18 | BufferedReader reader = new BufferedReader(new FileReader(fullFilenameWithPath)); 19 | 20 | String line = reader.readLine(); 21 | String html = ""; 22 | while (line != null) 23 | { 24 | html += StringEscapeUtils.escapeHtml(line); 25 | html += "
    "; 26 | line = reader.readLine(); 27 | } 28 | return html; 29 | 30 | } 31 | 32 | public String getFilename() { 33 | return this.fullFilenameWithPath; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TextConverter/src/main/java/tddmicroexercises/textconvertor/StringEscapeUtils.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor; 2 | 3 | class StringEscapeUtils { 4 | 5 | public static String escapeHtml(String input) { 6 | String output = input; 7 | output = output.replace("&", "&"); 8 | output = output.replace("<", "<"); 9 | output = output.replace(">", ">"); 10 | output = output.replace("\"", """); 11 | output = output.replace("'", """); 12 | return output; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TextConverter/src/test/java/tddmicroexercises/textconvertor/HtmlPagesConverterTest.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.IOException; 6 | 7 | import org.junit.Test; 8 | 9 | 10 | public class HtmlPagesConverterTest { 11 | @Test 12 | public void foo() throws IOException { 13 | HtmlPagesConverter converter = new HtmlPagesConverter("foo"); 14 | assertEquals("fixme", converter.getFilename()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TextConverter/src/test/java/tddmicroexercises/textconvertor/HtmlTextConverterTest.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class HtmlTextConverterTest { 8 | @Test 9 | public void foo() { 10 | HtmlTextConverter converter = new HtmlTextConverter("foo"); 11 | assertEquals("fixme", converter.getFilename()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TirePressureMonitoringSystem/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | TirePressureMonitoringSystem 5 | TirePressureMonitoringSystem 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | junit 10 | junit 11 | 4.9 12 | jar 13 | test 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-compiler-plugin 21 | 3.3 22 | 23 | 1.8 24 | 1.8 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TirePressureMonitoringSystem/src/main/java/tddmicroexercises/tirepressuremonitoringsystem/Alarm.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.tirepressuremonitoringsystem; 2 | 3 | public class Alarm 4 | { 5 | private final double LowPressureThreshold = 17; 6 | private final double HighPressureThreshold = 21; 7 | 8 | Sensor sensor = new Sensor(); 9 | 10 | boolean alarmOn = false; 11 | 12 | public void check() 13 | { 14 | double psiPressureValue = sensor.popNextPressurePsiValue(); 15 | 16 | if (psiPressureValue < LowPressureThreshold || HighPressureThreshold < psiPressureValue) 17 | { 18 | alarmOn = true; 19 | } 20 | } 21 | 22 | public boolean isAlarmOn() 23 | { 24 | return alarmOn; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TirePressureMonitoringSystem/src/main/java/tddmicroexercises/tirepressuremonitoringsystem/Sensor.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.tirepressuremonitoringsystem; 2 | 3 | import java.util.Random; 4 | 5 | // The reading of the pressure value from the sensor is simulated in this implementation. 6 | // Because the focus of the exercise is on the other class. 7 | 8 | public class Sensor { 9 | public static final double OFFSET = 16; 10 | 11 | public double popNextPressurePsiValue() { 12 | double pressureTelemetryValue; 13 | pressureTelemetryValue = samplePressure( ); 14 | 15 | return OFFSET + pressureTelemetryValue; 16 | } 17 | 18 | private static double samplePressure() { 19 | // placeholder implementation that simulate a real sensor in a real tire 20 | Random basicRandomNumbersGenerator = new Random(); 21 | double pressureTelemetryValue = 6 * basicRandomNumbersGenerator.nextDouble() * basicRandomNumbersGenerator.nextDouble(); 22 | return pressureTelemetryValue; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TirePressureMonitoringSystem/src/test/java/tddmicroexercises/tirepressuremonitoringsystem/TestAlarm.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.tirepressuremonitoringsystem; 2 | 3 | 4 | import org.junit.*; 5 | import static org.junit.Assert.*; 6 | 7 | public class TestAlarm { 8 | 9 | @Test 10 | public void foo() { 11 | Alarm alarm = new Alarm(); 12 | assertEquals(false, alarm.isAlarmOn()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TurnTicketDispenser/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | TurnTicketDispenser 5 | TurnTicketDispenser 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | junit 10 | junit 11 | 4.9 12 | jar 13 | test 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-compiler-plugin 21 | 3.3 22 | 23 | 1.8 24 | 1.8 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TurnTicketDispenser/src/main/java/tddmicroexercises/turnticketdispenser/TicketDispenser.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.turnticketdispenser; 2 | 3 | public class TicketDispenser 4 | { 5 | public TurnTicket getTurnTicket() 6 | { 7 | int newTurnNumber = TurnNumberSequence.getNextTurnNumber(); 8 | TurnTicket newTurnTicket = new TurnTicket(newTurnNumber); 9 | 10 | return newTurnTicket; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TurnTicketDispenser/src/main/java/tddmicroexercises/turnticketdispenser/TurnNumberSequence.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.turnticketdispenser; 2 | 3 | public class TurnNumberSequence 4 | { 5 | private static int _turnNumber = 0; 6 | 7 | public static int getNextTurnNumber() 8 | { 9 | return _turnNumber++; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Java/TurnTicketDispenser/src/main/java/tddmicroexercises/turnticketdispenser/TurnTicket.java: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.turnticketdispenser; 2 | 3 | public class TurnTicket 4 | { 5 | private final int turnNumber; 6 | 7 | public TurnTicket(int turnNumber) 8 | { 9 | this.turnNumber = turnNumber; 10 | } 11 | 12 | public int getTurnNumber() 13 | { 14 | return turnNumber; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/.gitignore: -------------------------------------------------------------------------------- 1 | /*.runner.bat 2 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/lib/.gitignore: -------------------------------------------------------------------------------- 1 | /jsl.default.conf 2 | /jsl.exe 3 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/telemetry-system-tests/telemetry-diagnostic-controls-test.js: -------------------------------------------------------------------------------- 1 | describe('Telemetry System', function () { 2 | 3 | describe('TelemetryDiagnosticControls', function () { 4 | 5 | it('CheckTransmission() should send a diagnostic message and receive a status message response', function () { 6 | 7 | var target = new TelemetryDiagnosticControls(); 8 | target.checkTransmission(); 9 | 10 | var result = target.readDiagnosticInfo(); 11 | 12 | }); 13 | 14 | }); 15 | 16 | }); 17 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/telemetry-system/telemetry-diagnostic-controls.js: -------------------------------------------------------------------------------- 1 | 2 | TelemetryDiagnosticControls = function() { 3 | 4 | this._diagnosticChannelConnectionString = function() { return '*111#'; }; 5 | this._diagnosticInfo = ''; 6 | this._telemetryClient = new TelemetryClient(); 7 | }; 8 | 9 | TelemetryDiagnosticControls.prototype = { 10 | 11 | readDiagnosticInfo: function() { 12 | return this._diagnosticInfo; 13 | }, 14 | 15 | writeDiagnosticInfo: function(newValue) { 16 | this._diagnosticInfo = newValue; 17 | }, 18 | 19 | checkTransmission: function() { 20 | 21 | this._diagnosticInfo = ''; 22 | 23 | this._telemetryClient.disconnect(); 24 | 25 | var retryLeft = 3; 26 | while (this._telemetryClient.onlineStatus() === false && retryLeft > 0) { 27 | this._telemetryClient.connect(this._diagnosticChannelConnectionString); 28 | retryLeft -= 1; 29 | } 30 | 31 | if (this._telemetryClient.onlineStatus() === false) { 32 | throw 'Unable to connect'; 33 | } 34 | 35 | this._telemetryClient.send(TelemetryClient.diagnosticMessage()); 36 | this._diagnosticInfo = this._telemetryClient.receive(); 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/tire-pressure-monitoring-system-tests/alarm-test.js: -------------------------------------------------------------------------------- 1 | describe('Tyre Pressure Monitoring System', function () { 2 | 3 | describe('Alarm', function () { 4 | 5 | it('Do something', function () { 6 | 7 | var target = new Alarm(); 8 | target.check(); 9 | 10 | }); 11 | 12 | }); 13 | 14 | }); 15 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/tire-pressure-monitoring-system/alarm.js: -------------------------------------------------------------------------------- 1 | 2 | Alarm = function() { 3 | 4 | this._lowPressureThreshold = 17; 5 | this._highPressureThreshold = 21; 6 | this._sensor = new Sensor(); 7 | this._alarmOn = false; 8 | }; 9 | 10 | Alarm.prototype = { 11 | 12 | check: function () { 13 | 14 | var psiPressureValue = this._sensor.popNextPressurePsiValue(); 15 | 16 | if (psiPressureValue < this._lowPressureThreshold || this._highPressureThreshold < psiPressureValue) 17 | { 18 | this._alarmOn = true; 19 | } 20 | }, 21 | 22 | alarmOn: function () { 23 | return this._alarmOn; 24 | } 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/tire-pressure-monitoring-system/sensor.js: -------------------------------------------------------------------------------- 1 | 2 | Sensor = function() { 3 | 4 | Sensor.Offset = function() { return 16; }; 5 | Sensor.SamplePressure = function() { 6 | // placeholder implementation that simulate a real sensor in a real tire 7 | 8 | var pressureTelemetryValue = Math.floor(6 * Math.random() * Math.random()); 9 | return pressureTelemetryValue; 10 | }; 11 | }; 12 | 13 | Sensor.prototype = { 14 | 15 | popNextPressurePsiValue: function () { 16 | var pressureTelemetryValue = Sensor.SamplePressure(); 17 | 18 | return Sensor.Offset() + pressureTelemetryValue; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/turn-ticket-dispenser-tests/ticket-dispenser-test.js: -------------------------------------------------------------------------------- 1 | describe('Turn Ticket Dispenser', function () { 2 | 3 | describe('TurnTicketDispenser', function () { 4 | 5 | it('Do something', function () { 6 | 7 | var target = new TicketDispenser(); 8 | 9 | }); 10 | 11 | }); 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/turn-ticket-dispenser/ticket-dispenser.js: -------------------------------------------------------------------------------- 1 | TicketDispenser = function() { 2 | }; 3 | 4 | TicketDispenser.prototype = { 5 | 6 | getTurnTicket: function () { 7 | 8 | var newTurnNumber = TurnNumberSequence.getNextTurnNumber(); 9 | var newTurnTicket = new TurnTicket(newTurnNumber); 10 | 11 | return newTurnTicket; 12 | } 13 | 14 | }; 15 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/turn-ticket-dispenser/turn-number-sequence.js: -------------------------------------------------------------------------------- 1 | 2 | TurnNumberSequence = { 3 | _turnNumber: 1, 4 | getNextTurnNumber: function() { 5 | return TurnNumberSequence._turnNumber++; 6 | } 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/turn-ticket-dispenser/turn-ticket.js: -------------------------------------------------------------------------------- 1 | TurnTicket = function(turnNumber) { 2 | 3 | this._turnNumber = turnNumber; 4 | }; 5 | 6 | TurnTicket.prototype = { 7 | 8 | turnNumber: function () { 9 | return this._turnNumber; 10 | } 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Javascript/unicode-file-to-html-text-converter-tests/unicode-file-to-html-text-converter-test.js: -------------------------------------------------------------------------------- 1 | describe('Unicode To Html Converter', function () { 2 | 3 | describe('UnicodeFileToHtmlTextConverter', function () { 4 | 5 | it('Do something', function () { 6 | 7 | var target = new UnicodeFileToHtmlTextConverter(); 8 | 9 | }); 10 | 11 | }); 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TelemetrySystem/telemetry.py: -------------------------------------------------------------------------------- 1 | from client import TelemetryClient 2 | 3 | class TelemetryDiagnostics: 4 | DiagnosticChannelConnectionString = "*111#" 5 | 6 | def __init__(self): 7 | self._telemetry_client = TelemetryClient() 8 | self.diagnostic_info = "" 9 | 10 | def check_transmission(self): 11 | self.diagnostic_info = "" 12 | self._telemetry_client.disconnect() 13 | 14 | retryLeft = 3 15 | while ((not self._telemetry_client.online_status) and retryLeft > 0): 16 | self._telemetry_client.connect(TelemetryDiagnostics.DiagnosticChannelConnectionString) 17 | retryLeft -= 1 18 | 19 | if not self._telemetry_client.online_status: 20 | raise Exception("Unable to connect.") 21 | 22 | self._telemetry_client.send(TelemetryClient.DIAGNOSTIC_MESSAGE) 23 | self.diagnostic_info = self._telemetry_client.receive() 24 | 25 | 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TelemetrySystem/test_telemetry.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from telemetry import * 4 | 5 | class TelemetryDiagnosticControlsTest(unittest.TestCase): 6 | def test_foo(self): 7 | diagnostics = TelemetryDiagnostics() 8 | self.assertEqual("foo", diagnostics.diagnostic_info) 9 | 10 | if __name__ == "__main__": 11 | unittest.main() -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TextConverter/test_text_converter.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from text_converter import UnicodeFileToHtmlTextConverter 3 | 4 | class UnicodeFileToHtmlTextConverterTest(unittest.TestCase): 5 | 6 | def test_foo(self): 7 | converter = UnicodeFileToHtmlTextConverter("foo") 8 | self.assertEqual("foo", converter.full_filename_with_path) 9 | 10 | if __name__ == "__main__": 11 | unittest.main() -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TextConverter/text_converter.py: -------------------------------------------------------------------------------- 1 | 2 | # This is for Python 3 3 | import html as html_converter 4 | 5 | # for Python 2 uncomment this line 6 | #import cgi as html_converter 7 | 8 | class UnicodeFileToHtmlTextConverter(object): 9 | 10 | def __init__(self, full_filename_with_path): 11 | self.full_filename_with_path = full_filename_with_path 12 | 13 | def convert_to_html(self): 14 | f = open(self.full_filename_with_path, "r") 15 | html = "" 16 | for line in f: 17 | line = line.rstrip() 18 | html += html_converter.escape(line, quote=True) 19 | html += "
    " 20 | 21 | return html -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TirePressureMonitoringSystem/sensor.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | class Sensor(object): 4 | 5 | # The reading of the pressure value from the sensor is simulated in this implementation. 6 | # Because the focus of the exercise is on the other class. 7 | 8 | _OFFSET = 16 9 | 10 | def pop_next_pressure_psi_value(self): 11 | pressure_telemetry_value = self.sample_pressure() 12 | return Sensor._OFFSET + pressure_telemetry_value 13 | 14 | @staticmethod 15 | def sample_pressure(): 16 | # placeholder implementation that simulate a real sensor in a real tire 17 | pressure_telemetry_value = 6 * random.random() * random.random() 18 | return pressure_telemetry_value 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TirePressureMonitoringSystem/test_tire_pressure_monitoring.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from tire_pressure_monitoring import Alarm 4 | 5 | class AlarmTest(unittest.TestCase): 6 | 7 | def test_alarm_is_off_by_default(self): 8 | alarm = Alarm() 9 | assert not alarm.is_alarm_on -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TirePressureMonitoringSystem/tire_pressure_monitoring.py: -------------------------------------------------------------------------------- 1 | from sensor import Sensor 2 | 3 | class Alarm(object): 4 | 5 | def __init__(self): 6 | self._low_pressure_threshold = 17 7 | self._high_pressure_threshold = 21 8 | self._sensor = Sensor() 9 | self._is_alarm_on = False 10 | 11 | def check(self): 12 | psi_pressure_value = self._sensor.pop_next_pressure_psi_value() 13 | if psi_pressure_value < self._low_pressure_threshold \ 14 | or self._high_pressure_threshold < psi_pressure_value: 15 | self._is_alarm_on = True 16 | 17 | @property 18 | def is_alarm_on(self): 19 | return self._is_alarm_on 20 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TurnTicketDispenser/test_turn_ticket.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from turn_ticket import TicketDispenser 4 | 5 | class TicketDispenserTest(unittest.TestCase): 6 | 7 | def test_do_something(self): 8 | dispenser = TicketDispenser() 9 | ticket = dispenser.getTurnTicket() 10 | 11 | 12 | if __name__ == "__main__": 13 | unittest.main() -------------------------------------------------------------------------------- /racing-car-katas/exercises/Python/TurnTicketDispenser/turn_ticket.py: -------------------------------------------------------------------------------- 1 | class TurnTicket(object): 2 | def __init__(self, turnNumber): 3 | self.turnNumber = turnNumber 4 | 5 | class TurnNumberSequence(object): 6 | _turnNumber = -1 7 | 8 | @staticmethod 9 | def next_turn_number(): 10 | TurnNumberSequence._turnNumber += 1 11 | return TurnNumberSequence._turnNumber 12 | 13 | 14 | class TicketDispenser(object): 15 | def getTurnTicket(self): 16 | newTurnNumber = TurnNumberSequence.next_turn_number() 17 | newTurnTicket = TurnTicket(newTurnNumber) 18 | return newTurnTicket 19 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | group :test do 4 | gem "rspec" 5 | end 6 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | diff-lcs (1.2.5) 5 | rspec (3.3.0) 6 | rspec-core (~> 3.3.0) 7 | rspec-expectations (~> 3.3.0) 8 | rspec-mocks (~> 3.3.0) 9 | rspec-core (3.3.2) 10 | rspec-support (~> 3.3.0) 11 | rspec-expectations (3.3.1) 12 | diff-lcs (>= 1.2.0, < 2.0) 13 | rspec-support (~> 3.3.0) 14 | rspec-mocks (3.3.2) 15 | diff-lcs (>= 1.2.0, < 2.0) 16 | rspec-support (~> 3.3.0) 17 | rspec-support (3.3.0) 18 | 19 | PLATFORMS 20 | ruby 21 | 22 | DEPENDENCIES 23 | rspec 24 | 25 | BUNDLED WITH 26 | 1.10.3 27 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TelemetrySystem/spec/telemetry_diagnostics_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../telemetry' 2 | 3 | describe TelemetryDiagnostics do 4 | context "#diagnostic_info" do 5 | it "returns the correct diagnostic info" do 6 | expect(TelemetryDiagnostics.new.diagnostic_info).to eq "foo" 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TelemetrySystem/telemetry.rb: -------------------------------------------------------------------------------- 1 | require './client' 2 | 3 | class TelemetryDiagnostics 4 | attr_reader :diagnostic_info 5 | DIAGNOSTIC_CHANNEL_CONNECTION_STRING = "*111#" 6 | 7 | def initialize 8 | @telemetry_client = TelemetryClient.new 9 | @diagnostic_info = "" 10 | end 11 | 12 | def check_transmission 13 | @diagnostic_info = "" 14 | @telemetry_client.disconnect 15 | 16 | retry_left = 3 17 | while (not @telemetry_client.online_status) and retry_left > 0 18 | @telemetry_client.connect(DIAGNOSTIC_CHANNEL_CONNECTION_STRING) 19 | retry_left -= 1 20 | end 21 | 22 | if not @telemetry_client.online_status 23 | raise Exception.new("Unable to connect.") 24 | end 25 | 26 | @telemetry_client.send(TelemetryClient::DIAGNOSTIC_MESSAGE) 27 | @diagnostic_info = @telemetry_client.receive 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TextConverter/html_pages.rb: -------------------------------------------------------------------------------- 1 | require 'cgi' 2 | class HtmlPagesConverter 3 | def initialize(filename) 4 | @filename = filename 5 | @breaks = [0] 6 | File.open(@filename, "r") do |f| 7 | f.each_line do |line| 8 | line = line.strip 9 | if line.include?("PAGE_BREAK") 10 | page_break_position = f.tell 11 | @breaks << f.tell 12 | end 13 | end 14 | @breaks << f.tell 15 | end 16 | end 17 | 18 | def get_html_page(page) 19 | # Return html page with the given page number 20 | # (zero-indexed) 21 | page_start = @breaks[page] 22 | page_end = @breaks[page + 1] 23 | html = "" 24 | File.open(@filename, "r") do |f| 25 | f.seek(page_start) 26 | while f.tell != page_end 27 | line = f.readline 28 | line = line.strip 29 | next if line.include?("PAGE_BREAK") 30 | html << CGI.escapeHTML(line) 31 | html << "
    " 32 | 33 | end 34 | end 35 | 36 | return html 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TextConverter/spec/text_converter_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../text_converter' 2 | describe UnicodeFileToHtmlTextConverter do 3 | context "#foo" do 4 | it "executes correctly" do 5 | converter = UnicodeFileToHtmlTextConverter.new("foo") 6 | 7 | expect(converter.full_path_to_file).to eq("foo") 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TextConverter/text_converter.rb: -------------------------------------------------------------------------------- 1 | require 'cgi' 2 | 3 | class UnicodeFileToHtmlTextConverter 4 | attr_reader :full_path_to_file 5 | 6 | def initialize(full_path_to_file) 7 | @full_path_to_file = full_path_to_file 8 | end 9 | 10 | def convert_to_html 11 | f = File.open(@full_path_to_file) 12 | html = "" 13 | f.each_line do |line| 14 | line = line.strip 15 | html << CGI.escapeHTML(line) 16 | html << "
    " 17 | end 18 | 19 | return html 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TirePressure/test_tire_pressure.rb: -------------------------------------------------------------------------------- 1 | require "test/unit" 2 | 3 | require 'tire_pressure' 4 | 5 | class TestAlarm < Test::Unit::TestCase 6 | 7 | def test_alarm_off_by_default 8 | assert(!Alarm.new().is_alarm_on) 9 | end 10 | 11 | end -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TirePressure/tire_pressure.rb: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Sensor 4 | OFFSET = 16 5 | 6 | def pop_next_pressure_psi_value 7 | Sensor.OFFSET + self.sample_pressure() 8 | end 9 | 10 | def self.sample_pressure 11 | # placeholder implementation that simulate a real sensor in a real tire 12 | 6 * rand * rand 13 | end 14 | 15 | end 16 | 17 | class Alarm 18 | 19 | attr_reader :is_alarm_on 20 | 21 | def initialize 22 | @low_pressure_threshold = 17 23 | @high_pressure_threshold = 21 24 | @sensor = Sensor.new() 25 | @is_alarm_on = false 26 | end 27 | 28 | def check 29 | psi_pressure_value = @sensor.pop_next_pressure_psi_value() 30 | if psi_pressure_value < @low_pressure_threshold or @high_pressure_threshold < psi_pressure_value 31 | @is_alarm_on = true 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TurnTicketDispenser/spec/turn_ticket_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../turn_ticket' 2 | 3 | describe TurnTicket do 4 | it "does something" do 5 | dispenser = TicketDispenser.new 6 | ticket = dispenser.get_turn_ticket 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/Ruby/TurnTicketDispenser/turn_ticket.rb: -------------------------------------------------------------------------------- 1 | class TurnTicket 2 | def initialize turn_number 3 | @turn_number = turn_number 4 | end 5 | end 6 | 7 | class TurnNumberSequence 8 | 9 | @@turn_number = -1 10 | 11 | def self.next_turn_number 12 | @@turn_number += 1 13 | 14 | @@turn_number 15 | end 16 | end 17 | 18 | class TicketDispenser 19 | def get_turn_ticket 20 | new_turn_number = TurnNumberSequence.next_turn_number 21 | new_turn_ticket = TurnTicket.new(new_turn_number) 22 | 23 | new_turn_ticket 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/build.sbt: -------------------------------------------------------------------------------- 1 | name := "RacingCarKatas" 2 | 3 | version := "1.0" 4 | 5 | scalaVersion := "2.10.2" 6 | 7 | libraryDependencies ++= List( 8 | "org.scalatest" % "scalatest_2.10" % "2.0", 9 | "org.mockito" % "mockito-all" % "1.10.19" 10 | ) -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/leaderboard/Driver.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.leaderboard 2 | 3 | class Driver(val name: String, val country: String) {} 4 | 5 | class SelfDrivingCar(var algorithmVersion: String, val company: String) extends Driver(algorithmVersion, company) 6 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/leaderboard/Leaderboard.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.leaderboard 2 | 3 | import scala.collection.mutable 4 | 5 | class Leaderboard(val races: List[Race]) { 6 | 7 | def driver_results(): Map[String, Int] = { 8 | val results = mutable.Map[String, Int]().withDefaultValue(0) 9 | races.foreach((race: Race) => { 10 | race.results.foreach((driver: Driver) => { 11 | val position = race.position(driver) 12 | val name = race.driverNames(position) 13 | results(name) += race.points(driver) 14 | }) 15 | }) 16 | results.toMap 17 | } 18 | 19 | def driver_rankings(): List[String] = { 20 | sortedRankings(driver_results()) 21 | } 22 | 23 | private def sortedRankings(results: Map[String, Int]): List[String] = { 24 | results.toList.sortBy(_._2).reverseMap(_._1) 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/leaderboard/Race.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.leaderboard 2 | 3 | class Race(val name: String, val results: List[Driver]) { 4 | 5 | val driverNames: List[String] = results.map( (driver: Driver ) => { 6 | if (driver.isInstanceOf[SelfDrivingCar]) { 7 | s"Self Driving Car - ${driver.country} (${driver.asInstanceOf[SelfDrivingCar].algorithmVersion})" 8 | } else { 9 | driver.name 10 | } 11 | }) 12 | 13 | def position(driver: Driver): Int = { 14 | results.indexOf(driver) 15 | } 16 | 17 | def points(driver: Driver): Int = { 18 | Race.points(position(driver)) 19 | } 20 | 21 | } 22 | 23 | object Race { 24 | val points: List[Int] = List(25, 18, 15) 25 | } 26 | 27 | -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/textconvertor/HtmlPagesConverter.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor 2 | 3 | import java.io.FileReader 4 | 5 | import java.io.BufferedReader 6 | import scala.util.control.Breaks._ 7 | 8 | class HtmlPagesConverter(val filename : String) { 9 | var breaks = List[Int](0) 10 | var reader = new BufferedReader(new FileReader(this.filename)) 11 | var cumulativeCharCount = 0 12 | var line = reader.readLine() 13 | while (line != null) 14 | { 15 | cumulativeCharCount += line.length() + 1 // add one for the newline 16 | if (line.contains("PAGE_BREAK")) { 17 | val page_break_position = cumulativeCharCount 18 | breaks :+ page_break_position 19 | } 20 | line = reader.readLine() 21 | } 22 | reader.close() 23 | 24 | def getHtmlPage(page : Int) : String = { 25 | reader = new BufferedReader(new FileReader(filename)) 26 | reader.skip(breaks(page)) 27 | var htmlPage = new StringBuffer() 28 | var line = reader.readLine() 29 | while (line != null) 30 | { 31 | if (line.contains("PAGE_BREAK")) { 32 | break 33 | } 34 | htmlPage.append(StringEscapeUtils.escapeHtml(line)) 35 | htmlPage.append("
    ") 36 | 37 | line = reader.readLine() 38 | } 39 | reader.close() 40 | return htmlPage.toString 41 | } 42 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/textconvertor/HtmlTextConverter.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor 2 | 3 | import java.io.{FileReader, BufferedReader} 4 | 5 | 6 | class HtmlTextConverter(val fullFilenameWithPath : String) { 7 | 8 | def convertToHtml() : String = { 9 | 10 | val reader = new BufferedReader(new FileReader(fullFilenameWithPath)) 11 | 12 | var line = reader.readLine() 13 | var html = "" 14 | while (line != null) 15 | { 16 | html += StringEscapeUtils.escapeHtml(line) 17 | html += "
    " 18 | line = reader.readLine() 19 | } 20 | return html 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/textconvertor/StringEscapeUtils.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor 2 | 3 | 4 | object StringEscapeUtils { 5 | def escapeHtml(input : String) : String = { 6 | var output = input 7 | output = output.replace("&", "&") 8 | output = output.replace("'", """) 9 | output = output.replace("<", "<") 10 | output = output.replace(">", ">") 11 | output = output.replace("\"", """) 12 | return output 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/tirepressuremonitoringsystem/Alarm.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.tirepressuremonitoringsystem 2 | 3 | class Alarm 4 | { 5 | val LowPressureThreshold : Double = 17 6 | val HighPressureThreshold : Double = 21 7 | 8 | val sensor = new Sensor() 9 | 10 | var alarmOn = false 11 | 12 | def check() 13 | { 14 | val psiPressureValue = sensor.popNextPressurePsiValue() 15 | 16 | if (psiPressureValue < LowPressureThreshold || HighPressureThreshold < psiPressureValue) 17 | { 18 | alarmOn = true 19 | } 20 | } 21 | 22 | def isAlarmOn() : Boolean = { 23 | return alarmOn 24 | } 25 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/tirepressuremonitoringsystem/Sensor.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.tirepressuremonitoringsystem 2 | 3 | import java.util.Random 4 | 5 | // The reading of the pressure value from the sensor is simulated in this implementation. 6 | // Because the focus of the exercise is on the other class. 7 | 8 | class Sensor { 9 | 10 | def popNextPressurePsiValue() : Double = { 11 | var pressureTelemetryValue : Double = 0 12 | pressureTelemetryValue = Sensor.samplePressure() 13 | 14 | return Sensor.OFFSET + pressureTelemetryValue 15 | } 16 | 17 | } 18 | 19 | object Sensor { 20 | 21 | val OFFSET : Double = 16 22 | 23 | private def samplePressure() : Double = { 24 | // placeholder implementation that simulate a real sensor in a real tire 25 | val basicRandomNumbersGenerator = new Random() 26 | val pressureTelemetryValue = 6 * basicRandomNumbersGenerator.nextDouble() * basicRandomNumbersGenerator.nextDouble() 27 | return pressureTelemetryValue 28 | } 29 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/turnticketdispenser/TicketDispenser.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.turnticketdispenser 2 | 3 | 4 | class TicketDispenser { 5 | def getTurnTicket() : TurnTicket = { 6 | var newTurnNumber = TurnNumberSequence.getNextTurnNumber() 7 | var newTurnTicket = new TurnTicket(newTurnNumber) 8 | 9 | return newTurnTicket 10 | } 11 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/turnticketdispenser/TurnNumberSequence.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.turnticketdispenser 2 | 3 | 4 | object TurnNumberSequence { 5 | private var turnNumber = 0 6 | 7 | def getNextTurnNumber() : Int = { 8 | turnNumber += 1 9 | return turnNumber 10 | } 11 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/main/scala/tddmicroexercises/turnticketdispenser/TurnTicket.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.turnticketdispenser 2 | 3 | 4 | class TurnTicket(val turnNumber : Int) { 5 | 6 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/test/scala/tddmicroexercises/textconvertor/HtmlPagesConverterTest.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor 2 | 3 | import org.scalatest.{Matchers, FlatSpec} 4 | 5 | 6 | class HtmlPagesConverterTest extends FlatSpec with Matchers { 7 | it should "foo" in { 8 | val converter = new HtmlPagesConverter("foo") 9 | converter.filename shouldEqual "fixme" 10 | } 11 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/test/scala/tddmicroexercises/textconvertor/HtmlTextConverterTest.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.textconvertor 2 | 3 | import org.scalatest.{Matchers, FlatSpec} 4 | 5 | 6 | class HtmlTextConverterTest extends FlatSpec with Matchers { 7 | it should "foo" in { 8 | val converter = new HtmlTextConverter("foo"); 9 | converter.fullFilenameWithPath shouldEqual "fixme" 10 | } 11 | } -------------------------------------------------------------------------------- /racing-car-katas/exercises/scala/src/test/scala/tddmicroexercises/tirepressuremonitoringsystem/TestAlarm.scala: -------------------------------------------------------------------------------- 1 | package tddmicroexercises.tirepressuremonitoringsystem 2 | 3 | import org.scalatest._ 4 | 5 | class TestAlarm extends FlatSpec with Matchers { 6 | 7 | it should "foo" in { 8 | val alarm = new Alarm() 9 | alarm.isAlarmOn() shouldBe false 10 | } 11 | } -------------------------------------------------------------------------------- /racing-car-katas/license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 @emilybache 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** Racing Car Kata - Tire Pressure Monitoring System & Unicode File To HTML Text Converter & Ticket Dispenser 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 14/06/2017 & 22/06/2017 & 28/06/2017 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | # Running the Kata 13 | 14 | ```bash 15 | npm i -g live-server 16 | live-server 17 | ``` 18 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/lib/.gitignore: -------------------------------------------------------------------------------- 1 | /jsl.default.conf 2 | /jsl.exe 3 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/tire-pressure-monitoring-system/alarm.js: -------------------------------------------------------------------------------- 1 | 2 | Alarm = function(sensor, min, max) { 3 | 4 | this._lowPressureThreshold = min; 5 | this._highPressureThreshold = max; 6 | this._sensor = sensor; 7 | this._alarmOn = false; 8 | }; 9 | 10 | Alarm.prototype = { 11 | 12 | check: function () { 13 | 14 | var psiPressureValue = this._sensor.popNextPressurePsiValue(); 15 | 16 | if (psiPressureValue < this._lowPressureThreshold || this._highPressureThreshold < psiPressureValue) 17 | { 18 | this._alarmOn = true; 19 | } 20 | }, 21 | 22 | alarmOn: function () { 23 | return this._alarmOn; 24 | } 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/tire-pressure-monitoring-system/sensor.js: -------------------------------------------------------------------------------- 1 | 2 | Sensor = function() { 3 | 4 | Sensor.Offset = function() { return 16; }; 5 | Sensor.SamplePressure = function() { 6 | // placeholder implementation that simulate a real sensor in a real tire 7 | 8 | var pressureTelemetryValue = Math.floor(6 * Math.random() * Math.random()); 9 | return pressureTelemetryValue; 10 | }; 11 | }; 12 | 13 | Sensor.prototype = { 14 | 15 | popNextPressurePsiValue: function () { 16 | var pressureTelemetryValue = Sensor.SamplePressure(); 17 | 18 | return Sensor.Offset() + pressureTelemetryValue; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/turn-ticket-dispenser/ticket-dispenser.js: -------------------------------------------------------------------------------- 1 | TicketDispenser = function(turnNumberSequence) { 2 | this.getTurnTicket = function () { 3 | 4 | var newTurnNumber = turnNumberSequence.getNextTurnNumber(); 5 | var newTurnTicket = new TurnTicket(newTurnNumber); 6 | 7 | return newTurnTicket; 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/turn-ticket-dispenser/turn-number-sequence.js: -------------------------------------------------------------------------------- 1 | TurnNumberSequence = function() { 2 | this._turnNumber = 1; 3 | 4 | this.getNextTurnNumber = function() { 5 | return this._turnNumber++; 6 | } 7 | }; 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/turn-ticket-dispenser/turn-ticket.js: -------------------------------------------------------------------------------- 1 | TurnTicket = function(turnNumber) { 2 | 3 | this._turnNumber = turnNumber; 4 | }; 5 | 6 | TurnTicket.prototype = { 7 | 8 | turnNumber: function () { 9 | return this._turnNumber; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /racing-car-katas/tabcorp/unicode-file-to-html-text-converter/unicode-file-to-html-text-converter.js: -------------------------------------------------------------------------------- 1 | UnicodeFileToHtmlTextConverter = function(fileBlob, symbolsMap) { 2 | this._fileBlob = fileBlob; 3 | this._symbolsMap = symbolsMap; 4 | }; 5 | 6 | UnicodeFileToHtmlTextConverter.prototype.convertToHtml = function() { 7 | return new Promise((resolve, reject) => { 8 | var fileReader = new FileReader(); 9 | fileReader.onload = (evt) => { 10 | var text = evt.target.result; 11 | var htmlLines = this._basicHtmlEncode(text); 12 | resolve(htmlLines); 13 | }; 14 | fileReader.readAsText(this._fileBlob); 15 | }); 16 | }; 17 | 18 | UnicodeFileToHtmlTextConverter.prototype._basicHtmlEncode = function (source) { 19 | var result = ''; 20 | 21 | for (let i=0, characterToConvert; characterToConvert = source.charAt(i); i++) { 22 | result += this._symbolsMap[characterToConvert] || characterToConvert; 23 | } 24 | 25 | return result; 26 | }; 27 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "automerge": true, 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /require-lint/README.md: -------------------------------------------------------------------------------- 1 | * **Format:** Mob Programming 2 | * **Kata:** Adding a new feature to require-lint library 3 | * **Where:** [TabCorp](https://www.tabcorp.com.au/) 4 | * **When:** 05/07/2017 5 | 6 | 7 | 8 | 9 | ## Require Lint 10 | 11 | Adding the possibility to add packages separated by commas instead of repeating the same flag multiple times. 12 | 13 | **Currently:** 14 | 15 | `require-lint --ignore-extra express --ignore-extra bootstrap --ignore-extra ejs` 16 | 17 | **After:** 18 | 19 | `require-lint --ignore-extra express,bootstrap,ejs` 20 | 21 | We can do it for all the flags, not only `--ignore-extra`. 22 | 23 | PR link: https://github.com/TabDigital/require-lint/pull/14 24 | Project: https://github.com/TabDigital/require-lint 25 | -------------------------------------------------------------------------------- /revenge-of-the-pancakes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "revenge-of-the-pancakes", 3 | "scripts": { 4 | "test": "mocha -w" 5 | }, 6 | "devDependencies": { 7 | "mocha": "5.2.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /roman-numerals/.nvmrc: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /roman-numerals/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "roman-numerals", 3 | "scripts": { 4 | "test": "mocha -w" 5 | }, 6 | "devDependencies": { 7 | "mocha": "5.2.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tennis-refactoring-kata/.nvmrc: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /tennis-refactoring-kata/TennisTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tennis Test 4 | 5 | 6 |
    Tests incomplete
    7 | 8 | 9 |
    CaseResult
    10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /warriorjs/README.md: -------------------------------------------------------------------------------- 1 | ## Kata: WarriorJS 2 | 3 | ### Description: 4 | 5 | This is a game designed to teach JavaScript and artificial intelligence in a fun, interactive way. 6 | 7 | You play as a warrior climbing a tall tower to `[insert something motivating here]` at the top level. On each floor, you need to write JavaScript to instruct the warrior to battle enemies, rescue captives, and reach the stairs. 8 | 9 | **More details:** https://github.com/olistic/warriorjs 10 | -------------------------------------------------------------------------------- /warriorjs/tabcorp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "warriorjs": "3.0.0" 4 | }, 5 | "scripts": { 6 | "start": "warriorjs" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /warriorjs/tabcorp/warriorjs/dojoer-beginner/.profile: -------------------------------------------------------------------------------- 1 | eyJfdG93ZXJQYXRoIjoiL1VzZXJzL3JvZG9sZm9wcnIvUHJvamVjdHMvY29kaW5nLWRvam8vd2FycmlvcmpzL25vZGVfbW9kdWxlcy93YXJyaW9yanMvdG93ZXJzL2JlZ2lubmVyIiwiX3dhcnJpb3JOYW1lIjoiRG9qb2VyIiwiX3Njb3JlIjo5NywiX2VwaWMiOmZhbHNlLCJfZXBpY1Njb3JlIjowLCJfY3VycmVudEVwaWNTY29yZSI6MCwiX2N1cnJlbnRFcGljR3JhZGVzIjp7fSwiX2F2ZXJhZ2VHcmFkZSI6bnVsbCwiX2FiaWxpdGllcyI6W3sibmFtZSI6IndhbGsiLCJhcmdzIjpbXX0seyJuYW1lIjoiYXR0YWNrIiwiYXJncyI6W119LHsibmFtZSI6ImZlZWwiLCJhcmdzIjpbXX0seyJuYW1lIjoiaGVhbHRoIiwiYXJncyI6W119LHsibmFtZSI6InJlc3QiLCJhcmdzIjpbXX1dLCJfbGV2ZWxOdW1iZXIiOjQsIl9sYXN0TGV2ZWxOdW1iZXIiOm51bGwsIl9wbGF5ZXJQYXRoIjoid2FycmlvcmpzL2Rvam9lci1iZWdpbm5lciJ9 -------------------------------------------------------------------------------- /warriorjs/tabcorp/warriorjs/dojoer-beginner/Player.js: -------------------------------------------------------------------------------- 1 | const Resting = { 2 | turn: (context, warrior) => { 3 | if (context.isUnderAttack(warrior) || warrior.health() == 20) { 4 | context.state = Walking; 5 | context.state.turn(context, warrior); 6 | } else { 7 | warrior.rest(); 8 | } 9 | } 10 | }; 11 | 12 | const Attacking = { 13 | turn: (context, warrior) => { 14 | if (warrior.feel().isEmpty()) { 15 | if (warrior.health() < 20) { 16 | context.state = Resting; 17 | context.state.turn(context, warrior); 18 | } else { 19 | context.state = Walking; 20 | context.state.turn(context, warrior); 21 | } 22 | } else { 23 | warrior.attack(); 24 | } 25 | } 26 | }; 27 | 28 | const Walking = { 29 | turn: (context, warrior) => { 30 | if (!warrior.feel().isEmpty()) { 31 | context.state = Attacking; 32 | context.state.turn(context, warrior); 33 | } else { 34 | warrior.walk(); 35 | } 36 | } 37 | }; 38 | 39 | class Player { 40 | playTurn(warrior) { 41 | this.state = this.state || Walking; 42 | this.state.turn(this, warrior); 43 | 44 | this._health = warrior.health(); 45 | } 46 | 47 | isUnderAttack(warrior) { 48 | return warrior.health() < this._health; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /warriorjs/tabcorp/warriorjs/dojoer-beginner/README: -------------------------------------------------------------------------------- 1 | Level 4 2 | 3 | You can hear bow strings being stretched. 4 | 5 | Tip: No new abilities this time, but you must be careful not to rest while taking damage. Save a `_health` variable and compare it on each turn to see if you're taking damage. 6 | 7 | 8 | ╔═══════╗ 9 | ║@ Sa S>║ 10 | ╚═══════╝ 11 | 12 | > = stairs 13 | @ = Dojoer 14 | a = archer 15 | S = thickSludge 16 | 17 | 18 | Warrior abilities: 19 | 20 | warrior.walk() 21 | 22 | warrior.attack() 23 | 24 | warrior.feel() 25 | 26 | warrior.health() 27 | 28 | warrior.rest() 29 | 30 | 31 | When you're done editing Player.js, run the warriorjs command again. 32 | -------------------------------------------------------------------------------- /warriorjs/tabcorp/warriorjs/lethaldose-beginner/.profile: -------------------------------------------------------------------------------- 1 | eyJfdG93ZXJQYXRoIjoiL1VzZXJzL3JvZG9sZm9wcnIvUHJvamVjdHMvY29kaW5nLWRvam8vd2FycmlvcmpzL3RhYmNvcnAvbm9kZV9tb2R1bGVzL3dhcnJpb3Jqcy90b3dlcnMvYmVnaW5uZXIiLCJfd2Fycmlvck5hbWUiOiJsZXRoYWxkb3NlIiwiX3Njb3JlIjo1NDcsIl9lcGljIjp0cnVlLCJfZXBpY1Njb3JlIjowLCJfY3VycmVudEVwaWNTY29yZSI6MCwiX2N1cnJlbnRFcGljR3JhZGVzIjp7fSwiX2F2ZXJhZ2VHcmFkZSI6bnVsbCwiX2FiaWxpdGllcyI6W3sibmFtZSI6IndhbGsiLCJhcmdzIjpbXX0seyJuYW1lIjoiYXR0YWNrIiwiYXJncyI6W119LHsibmFtZSI6ImZlZWwiLCJhcmdzIjpbXX0seyJuYW1lIjoiaGVhbHRoIiwiYXJncyI6W119LHsibmFtZSI6InJlc3QiLCJhcmdzIjpbXX0seyJuYW1lIjoicmVzY3VlIiwiYXJncyI6W119LHsibmFtZSI6InBpdm90IiwiYXJncyI6W119LHsibmFtZSI6Imxvb2siLCJhcmdzIjpbXX0seyJuYW1lIjoic2hvb3QiLCJhcmdzIjpbXX1dLCJfbGV2ZWxOdW1iZXIiOjAsIl9sYXN0TGV2ZWxOdW1iZXIiOjksIl9wbGF5ZXJQYXRoIjoiLiJ9 -------------------------------------------------------------------------------- /warriorjs/tabcorp/warriorjs/lethaldose-beginner/README: -------------------------------------------------------------------------------- 1 | Level 9 2 | 3 | Time to hone your skills and apply all of the abilities that you have learned. 4 | 5 | Tip: Watch your back. 6 | 7 | 8 | ╔═══════════╗ 9 | ║>Ca @ S wC║ 10 | ╚═══════════╝ 11 | 12 | > = stairs 13 | @ = lethaldose 14 | a = archer 15 | S = thickSludge 16 | w = wizard 17 | C = captive 18 | 19 | 20 | Warrior abilities: 21 | 22 | warrior.walk() 23 | 24 | warrior.attack() 25 | 26 | warrior.feel() 27 | 28 | warrior.health() 29 | 30 | warrior.rest() 31 | 32 | warrior.rescue() 33 | 34 | warrior.pivot() 35 | 36 | warrior.look() 37 | 38 | warrior.shoot() 39 | 40 | 41 | When you're done editing Player.js, run the warriorjs command again. 42 | --------------------------------------------------------------------------------