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.
- Preparing your machine
- Pagination Kata
- Understanding solution
- Licensing
- Contacts
- Credits
- Download the package and unzip it. Next, import the project inside the Java folder as a Maven project inside Eclipse.
-
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
-
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.
-
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
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]