https://github.com/bilelmsekni/pagination-kata
Kata for CleanCode, TDD on brown field and BDD
https://github.com/bilelmsekni/pagination-kata
autofixture dotnet java nsubstitute nunit tdd-kata
Last synced: 6 months ago
JSON representation
Kata for CleanCode, TDD on brown field and BDD
- Host: GitHub
- URL: https://github.com/bilelmsekni/pagination-kata
- Owner: bilelmsekni
- License: mit
- Created: 2016-12-15T08:24:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-10T09:18:08.000Z (over 8 years ago)
- Last Synced: 2025-02-13T20:40:09.972Z (8 months ago)
- Topics: autofixture, dotnet, java, nsubstitute, nunit, tdd-kata
- Language: C#
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Pagination-Kata
===============================This Kata will help candidates learn about TDD development on green and brown fields.
The .Net version is using NUnit & NSubstitute while the Java implementation is based on JUnit and mockito.Table of Contents
=================1. Preparing your machine
2. Pagination Kata
3. Understanding solution
4. Licensing
5. Contacts
6. CreditsPreparing your machine
===============1.1. Java
-----------------* Download the package and unzip it. Next, import the project inside the Java folder as a Maven project inside Eclipse.
2.1. Installing Visual Studio
-----------------* Download visual studio installation from the link below and install it on your machine:
https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
2.2. Adding Visual Studio extensions
--------------------------------* Because we will be using Nunit, it will be useful to add Nunit test adapter 3 extension to visual studio in order to run tests from within the test explorer:
Open Visual Studio and go to Tools > Extensions and Updates.
Search for NUnit test adapter on the online gallery and add it.2.3. Creating the test project
---------------------------* Finally, create a new library project and add reference to the following packages via Nuget Manager console:
Open Visual Studio and go to Tools > NuGet package manager > NuGet package manager console and type these commands.
Install-Package NUnit
Install-Package NSubstitute
Pagination Kata
===============You would like to paginate the items you are retrieving from the database before displaying them on a certain page.
In order to do so, you need to return the first and last page numbers. The Previous and next page numbers of the required page.The rules are:
- The database can return 0 or more items.
- First page number is 0 if there are no items to display.
- Last page number is 0 if there are no items to display.
- Previous page number is:
* -1 if there are no items to display
* 0 if previous page does not exist.
* else required page - 1
- Next page number is:
* -1 if there are no items to display
* 0 if next page does not exist.
* required page + 1
Examples:
Given the items count is 7
And the number of items per page is 2
And the required page is 2
When i paginate
Then the first page is 1
And the last page is 4
And the previous page is 1
And the next page is 3
And the items displayed in page are [3,4]