This is a sudoku generating single page application(SPA) written using ASP.NET, C#, MVC, jQuery, CSS, HTML and Bootstrap. SPA calls the Web API written in MVC and display valid sudoku puzzle with a unique solution each time you call the service.
These instructions explain how to build and run this project on your local machine for development and/or testing purposes.
Microsoft Visual Studio 2017 (.Net Framework 4.6.1)
Postman
- Open the SudokuGenerator.sln file in Visual Studio.
- To build the project, choose Build Solution from the Build menu. The Output window shows the results of the build process.
- To run, on the menu bar, choose Debug, Start debugging/Start without debugging or by pressing F5. This will open the browser and run the project with https://localhost:64858 and will display the valid sudoku puzzle. It's also accessible via URL https://localhost:64858/home/index
To call the web api from Postman, use URL http://localhost:64852/sudoku/board using the GET request type.
Tests will run automatically when you build/rebuild the solution in MS Visual Studio.
To run manually in MS Visual Studio: Test -> Windows -> Test Explorer -> Run All
You can also run the tests in command prompt by following instructions given below:
- Run command prompt as an Administrator
- Navigate to the path which has Vstest.console.exe file in your machine in command prompt. For example: cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow
- Run command: Vstest.console.exe "path to the test project dll". For example: Vstest.console.exe "E:\SudokuGenerator\SudokuGenerator\SudokuGenerator.Tests\bin\Debug\SudokuGenerator.Tests.dll"
Test will call functions from the api project SudokuGenerator and check for validity of generated sudoku.
Valid Sudoku:
ValidateSudokuBoard() will return true as it compliance with all the rules of sudoku.
Rules:
- All 9 sub grid of 3×3 has unique elements from 1-9
- All rows contains unique elements beween 1-9
- All columns contains unique elements beween 1-9
Invalid Sudoku Board:
ValidateSudokuBoard() will return false as it violates the rules of sudoku.
Rules Violated
- 4 is twice in 3rd row
- 4 is twice in 1st 3*3 sub grid
- 6 is twice in 7th row
- 6 is twice in 6th column
- 0 is present in 5th column
- Nilam Savani - Initial work - Nilam Savani