▶️Testing a web app
Testing a web app using XUnit
This is a simple asp.net core Razor Pages application to calculate the age of a person when he enters his date of birth in the home page. The result is shown in a second page after he click the submit.
The VSCode solution has 3 projects- one to hold the core logic (a class library), another to perform the testing of this core logic (XUnit project) and finally the last one is the actual web application for the end user.
Screen shots


Repository for the above app
Clone the above repo
git clone https://github.com/ravirammysore/KnowYourAge.git
Requirements to run the app
VSCode IDE
C# Extension for VS Code
.NET Core Test Explorer (for visual interface)
Commands for installing the above requirements
dotnet --version
winget install dotnet-sdk-7
code --install-extension ms-dotnettools.csharp
code --install-extension formulahendry.dotnet-test-explorer
If you need to know how the project structure was created using VSCode and .net CLI, you can look into this documentation.
Run the application
Close visual studio code and any command prompts if open
Open a command to the inner folder where the app is cloned, example C:\Users\ravi_\Source\repos\Temp\KnowYourAge\KnowYourAge
Issue the command
code .
(This should load the project in VSCode properly)
Accept any suggestions by VS Code to restore assets, packages or extensions
Use ctrl and F5 keys to run the application!
Accept any prompts regarding security certificate from your browser
Ignore warning by browser
Your browser may warn about connection, click Advanced
and then click the localhost.... link to start browsing the app!
You could also try installing the certificate manually as shown below:
Install the certificate
dotnet dev-certs https --trust

Last updated