|
1 |
| -TestStack.ConventionTests |
2 |
| -========================= |
3 |
| - |
4 |
| -### What is ConventionTests? |
5 |
| -Convention over Configuration is a great way to cut down repetitive boilerplate code. |
6 |
| -But how do you validate that your code adheres to your conventions? |
7 |
| -TestStack.ConventionTests is a simple NuGet library that makes it easy to build validation rules for convention validation tests. |
8 |
| - |
9 |
| -TestStack.ConventionTests also will generate a convention report of the conventions present in your codebase, which you can publish as **living documentation** |
10 |
| - |
11 |
| -### Using ConventionTests |
12 |
| - |
13 |
| - [Test] |
14 |
| - public void DomainHasVirtualMethodsConvention() |
15 |
| - { |
16 |
| - // Define some data |
| 1 | +TestStack.ConventionTests |
| 2 | +========================= |
| 3 | + |
| 4 | +### What is ConventionTests? |
| 5 | +Convention over Configuration is a great way to cut down repetitive boilerplate code. |
| 6 | +But how do you validate that your code adheres to your conventions? |
| 7 | +TestStack.ConventionTests is a simple NuGet library that makes it easy to build validation rules for convention validation tests. |
| 8 | + |
| 9 | +TestStack.ConventionTests also will generate a convention report of the conventions present in your codebase, which you can publish as **living documentation** |
| 10 | + |
| 11 | +### Using ConventionTests |
| 12 | + |
| 13 | + [Test] |
| 14 | + public void DomainHasVirtualMethodsConvention() |
| 15 | + { |
| 16 | + // Define some data |
17 | 17 | var nHibernateEntities = Tpes.InAssemblyOf<SampleDomainClass>()
|
18 | 18 | .ConcreteTypes().InNamespace(typeof (SampleDomainClass).Namespace)
|
19 |
| - .ToTypes("nHibernate Entitites"); |
20 |
| - |
21 |
| - // Apply convention to data |
22 |
| - Convention.Is(new AllMethodsAreVirtual(), nhibernateEntities); |
23 |
| - } |
24 |
| - |
25 |
| -For more information [view the TestStack.ConventionTests documentation](http://docs.teststack.net/conventiontests/index.html) |
26 |
| - |
27 |
| -### Packaged Conventions |
28 |
| -Here is a list of some of the pacakged conventions |
29 |
| - |
30 |
| - - **AllClassesHaveDefaultConstructor** - All classes in defined data must have a default ctor (protected or public) |
31 |
| - - **AllMethodsAreVirtual** - All classes in defined data must have virtual methods (includes get_Property/set_Property backing methods) |
32 |
| - - **ClassTypeHasSpecificNamespace** - For example, Dto's must live in the Assembly.Dtos namespace' |
33 |
| - - **FilesAreEmbeddedResources** - All .sql files are embedded resources |
34 |
| - - **ProjectDoesNotReferenceDllsFromBinOrObjDirectories** - Specified project file must not reference assemblies from bin/obj directory |
35 |
| - - **MvcControllerNameAndBaseClassConvention** - Enforces MVC controller naming conventions |
36 |
| - - Types ending in *Controller must inherit from Controller (or ApiController), and |
37 |
| - - Types inheriting from ControllerBase must be named *Controller |
38 |
| - - **MvcControllerNameAndBaseClassConvention** - Enforces WebApi controller naming conventions |
39 |
| - - Types ending in *Controller must inherit from ApiController (or Controller), and |
40 |
| - - Types inheriting from ApiController must be named *Controller |
41 |
| - |
42 |
| -If you would like to define your own conventions see [Defining Conventions](http://docs.teststack.net/ConventionTests/DefiningConventions.html) |
43 |
| - |
44 |
| -### Where to find out more |
45 |
| -[Krzysztof Koźmic](https://github.com/kkozmic) spoke about ConventionTests at NDC 2012. You can find the video of that talk [here](http://vimeo.com/43676874), slides [here](http://kozmic.pl/presentations/) and the introductory blog post [here](http://kozmic.pl/2012/06/14/using-conventiontests/). |
46 |
| - |
47 |
| -[TestStack.ConventionTests documentation](http://docs.teststack.net/conventiontests/index.html) |
| 19 | + .ToTypes("nHibernate Entitites"); |
| 20 | + |
| 21 | + // Apply convention to data |
| 22 | + Convention.Is(new AllMethodsAreVirtual(), nhibernateEntities); |
| 23 | + } |
| 24 | + |
| 25 | +For more information [view the TestStack.ConventionTests documentation](http://docs.teststack.net/conventiontests/index.html) |
| 26 | + |
| 27 | +### Packaged Conventions |
| 28 | +Here is a list of some of the pacakged conventions |
| 29 | + |
| 30 | + - **AllClassesHaveDefaultConstructor** - All classes in defined data must have a default ctor (protected or public) |
| 31 | + - **AllMethodsAreVirtual** - All classes in defined data must have virtual methods (includes get_Property/set_Property backing methods) |
| 32 | + - **ClassTypeHasSpecificNamespace** - For example, Dto's must live in the Assembly.Dtos namespace' |
| 33 | + - **FilesAreEmbeddedResources** - All .sql files are embedded resources |
| 34 | + - **ProjectDoesNotReferenceDllsFromBinOrObjDirectories** - Specified project file must not reference assemblies from bin/obj directory |
| 35 | + - **MvcControllerNameAndBaseClassConvention** - Enforces MVC controller naming conventions |
| 36 | + - Types ending in *Controller must inherit from Controller (or ApiController), and |
| 37 | + - Types inheriting from ControllerBase must be named *Controller |
| 38 | + - **MvcControllerNameAndBaseClassConvention** - Enforces WebApi controller naming conventions |
| 39 | + - Types ending in *Controller must inherit from ApiController (or Controller), and |
| 40 | + - Types inheriting from ApiController must be named *Controller |
| 41 | + |
| 42 | +If you would like to define your own conventions see [Defining Conventions](http://docs.teststack.net/ConventionTests/DefiningConventions.html) |
| 43 | + |
| 44 | +### More Information |
| 45 | +[Krzysztof Koźmic](https://github.com/kkozmic) first spoke about ConventionTests at NDC 2012. You can find the video of that talk [here](http://vimeo.com/43676874), slides [here](http://kozmic.pl/presentations/) and the introductory blog post [here](http://kozmic.pl/2012/06/14/using-conventiontests/). |
| 46 | + |
| 47 | +In v2, we have rewritten convention tests from the ground up to make it easier to get started, bundle some default conventions and also decouple it from a specific unit testing framework. |
| 48 | + |
| 49 | +There is still plenty we can make better, so please raise issues on github with suggestions! |
| 50 | + |
| 51 | +Docs are available at [TestStack.ConventionTests documentation](http://docs.teststack.net/conventiontests/index.html) |
0 commit comments