This repository contains the test exercises from the lecture "Angewandte Testverfahren" from the forth FH semester.
- Who watches the watchman? (Testing functionality of a web application)
- To kill a Mockingbird (Using Mocks to test a library)
Prepare a comprehensive test that covers the functionality of the Tour of Heroes Web Application. Evaluate the functionality of the application and implement a test using Selenium for browser automation.
The assignment will be graded based on
- Test Coverage
- Code Quality
- Documentation
- Followed Test Practices
interface IWarehouse
{
bool HasProduct(string product);
int CurrentStock(string product);
void AddStock(string product, int amount);
void TakeStock(string product, int amount);
}
- All methods throw for invalid product names (null or empty).
- CurrentStock throws NoSuchProductException when called with a product for which HasProduct returns false.
- TakeStock throws NoSuchProductException when called with a product for which HasProduct returns false.
- TakeStock throws InsufficientStockException when called with an amount that exceeds what is currently stored. The Order class is used for filling individual orders from a warehouse.
Its interface is defined as such:
class Order
{
Order(string product, int amount);
bool IsFilled();
bool CanFillOrder(IWarehouse warehouse);
void Fill(IWarehouse warehouse);
}
- The constructor throws for invalid product names (null or empty) and amounts <1
- IsFilled starts out with false and becomes true once Fill has been called successfully.
- Fill rethrows any exceptions thrown by IWarehouse
- Fill throws OrderAlreadyFilled when Fill is called for an order that has already been filled
- CanFillOrder uses IWarehouse.HasProduct and IWarehouse.CurrentStock to check whether an order can be filled Implement and test both the Order class and an implementation of IWarehouse. When testing the Order class, use both your custom implementation of IWarehouse as well as Mock objects for testing the behaviour of Order.
Use MOQ or an equivalent Mocking library of your choice.