In this exercise you must apply the Decorator Design Pattern - twice!
Read and understand the example DecoratedBook.
In this exercise you must make something very similar.
In Visual Studio create a new Solution, type Console Application. Name the solution DecoratedTeacher.
Create a class Teacher with properties like Name and Salary.
And methods like ToString() and Equals(Object obj).
Extract an interface from the class Teacher. Name the interface ITeacher.
Visual Studio (or rather Resharper) can help you extracting the interface.
Create a class UnmodifiableTeacher. This class must implement the interface ITeacher, and have a reference to an object of type ITeacher.
All modifying methods and properties must throw NotSupportedException.
Unit test UnmodifiableTeacher.
For inspiration refer to the DecoratedBook example.
Do not forget to test the Equals(Object obj) method.
See that you test has good coverage.
The Teacher class is not thread safe.
Create a class ThreadSafeTeacher. This class must implement the interface ITeacher, and have a reference to an object of type ITeacher.
The class must be thread safe: Use lock(...) { ... }
Unit test ThreadSafeTeacher.
For inspiration refer to the DecoratedBook example.
Do not forget to test the Equals(Object obj) method.
See that you test has good coverage.