Understanding the SilverUnit source code
The SilverUnit source code is comprised of several projects:
- EventsHelper.csproj : this is a special C# project that is used by the SilverUnit assembly. It allows dynamically registering to events of unknown signatures and asserting the events were raised. it has nothing to do with silverlight.
- SilverUnit.vbproj : the main source for SilverUnit.
- Under the SilverUnit.ExampleTests folder, there are three projects
- ControlsUnderTest.csproj : this that taken from the silverlight toolkit. This is a silverlight class library project. our tests run against it.
- ControlTests.VB.vbproj : this is where the bulk of the example tests are located
- ControlTests.CS.csproj : contains some C# examples of the same VB tests. (not comprehensive)
Focusing on SilverUnit.vbproj
SilverUnit is comprised of several key players:
- Aspects - classes that inherit from the Aspect base class (from the CThru Engine)
- Redirects - classes that are used to "re-implement" existing methods of common Silverlight base types such as DependencyObject or ItemCollection. Some of the Aspects use the Typemock Isolator
RedirectCalls() method (in C# this is the "Isolate.Swap.CallsOn(..)" method. These are used extensively in SilverUnit - they make things much easier.
- Extensions - Extension methods for various types in the code, such as Firing custom events