A coding exercise from the udemy course C# intermediate
Report Bug
·
Request Feature
- About the Project
- What I learned from this project
- Getting Started
- Usage
- Roadmap
- Contributing
- License
- Contact
- Acknowledgements
It is a simple stopwatch app with a short test that prints to the console.
I wrote all of the exercises for this course using the TDD approach of writing tests first and then production code. The tests are written using xUnit and Fluent Assertions.
Thank you Mosh Hamedani for making a comprehensive and easy to follow course. ⭐
A list of commonly used resources that I found helpful are listed in the acknowledgements.
The code was written in Visual Studio.
The test coverage was measured with JetBrains dotCover.
The given specifications were:
-
Design a class called Stopwatch. The job of this class is to simulate a stopwatch. It should provide two methods: Start and Stop. We call the start method first, and the stop method next. Then we ask the stopwatch about the duration between start and stop. Duration should be a value in TimeSpan. Display the duration on the console.
-
We should also be able to use a stopwatch multiple times. So we may start and stop it and then start and stop it again. Make sure the duration value each time is calculated properly.
-
We should not be able to start a stopwatch twice in a row (because that may overwrite the initial start time). So the class should throw an InvalidOperationException if its started twice.
How to use DateTime and TimeSpan.
To get a local copy up and running follow these simple example steps.
Visual Studio needs to be installed along with the dotnet core runtime and SDK All can be installed by the Visual Studio installer.
- The installer can be found on this page
[Visual Studio documentation](https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio?view=vs-2019)
- Open Terminal
- Navigate to the directory where you want to install the files
- Clone the repo
git clone https://github.com/mpbmpb/stopwatch.git
- go to the stopwatch directory
cd stopwatch
- run the app from the terminal
dotnet run
- or find the stopwatch.sln file in your explorer and double click it. Visual Studio should take it from there.
This project is meant purely as an educational exercise.
There are currently no plans to expand this project. Feel free to contribute if you want to add something.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Feel free to contact me if you have questions or suggestions.
Mark van den Beemt - markkeyster@gmail.com
Project Link: https://github.com/mpbmpb/stopwatch