An HTTP API that simulates an internet-connected coffee machine.
- .NET 9
- ASP.NET Core
- xUnit (for testing)
- Moq (for mocking)
- Swagger (API documentation)
- .NET SDK
- (Optional) Visual Studio or Visual Studio Code
# Restore dependencies
dotnet restore
# Test the application
dotnet test
# Run the application
dotnet run --project ReadyTech
-
Returns a
200 OK
with:- A status message based on current temperature.
- The current UTC time.
-
Every 5th call returns:
503 Service Unavailable
— simulating the machine running out of coffee.
-
On April 1st, always returns:
418 I'm a teapot
— no coffee on April Fool’s Day.
-
Includes temperature-based messages using OpenWeatherMap:
- Above 30°C → "Your refreshing iced coffee is ready"
- 30°C or below → "Your piping hot coffee is ready"
The coffee message depends on real-time temperature in Melbourne, fetched from the OpenWeatherMap API.
To use the weather feature, you need an OpenWeatherMap API key. You can set it in either of the following ways:
{
"WeatherApi": {
"ApiKey": "your-api-key-here"
}
}
dotnet user-secrets init
dotnet user-secrets set "WeatherApi:ApiKey" "your-api-key-here"
💡 Your key will be automatically injected via
IConfiguration
.
Once the app is running, access interactive API docs at:
http://localhost:5153/swagger/index.html