Thursday, November 19, 2009

BDD for Dynamic Types with mspec

This one will be my 2nd post about mspec. The first on can be found here.

I am still newbie in Mspec crazy syntax!! but have done a lot of TDD (after all BDD is TDD) , so my 1st effort of using mspec to describe all specifications (=expression of behaviors) for dynamic types module, along with some refactoring produced the following output

------ Test started: Assembly: eXpand.Tests.dll ------
ModuleCreator, When Creating Dynamic Module
»
should return a list of module base descenants
ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers that exist already
» should not throw any exceptions
ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers
»
should find that member through xpdictionary
» should create typedattributes ExistentTypesMemberCreator,
When Creating ExistentTypes ReferenceMembers
» should find that member through xpdictionary
» should create typedattributes ExistentTypesMemberCreator,
When Creating ExistentTypes CollectionMembers
» should find that member through xpdictionary
» should create typedattributes WorldCreatorModule,
When SettingUp Module
» should contain dynamic modules within Application Modules collection
» should not load modelDiffs from dynamic assemblies
» should create Existent Classes Member WorldCreatorModule,
When Updating Model
» should display owner column to extended members list view
» should remove dynamic assemblies from Assemblies image Node WorldCreatorModule,
When Application Setup Is Completed
» should merge any mergable dynamic type
PersistentClassInfoTypeBuilder specs, When Creating An Assembly
» should Create An Assembly In Current AppDomain
PersistentClassInfoTypeBuilder specs, When Defining A DynamicType
» should Create A Dynamic Type
» should have A Constructor with Session as parameter
PersistentClassInfoTypeBuilder specs, When Requesting A Property With Reflection
» should find a property
» should be of Correct Type
PersistentClassInfoTypeBuilder specs, When Invoking A Property
» should have value
PersistentClassInfoTypeBuilder specs, When Creating A reference Property of dynamic type
» should find the property thourgh reflection
» should be ofthe correct referenced type
PersistentClassInfoTypeBuilder specs, When Creating A reference Property of existent type
» should find the property thourgh reflection
» should be ofthe correct referenced type
PersistentClassInfoTypeBuilder specs, When Invoking A Dynamic Reference Property
» should have the correct value
PersistentClassInfoTypeBuilder specs, When Creating A Collection Property
» should find the propertyInfo through reflection
PersistentClassInfoTypeBuilder specs, When Invoking A Dynamic Collection Property
» should not have value
PersistentClassInfoTypeBuilder specs, When Applying Attributes To Properties
» should be discovarable thourgh reflection
PersistentClassInfoTypeBuilder specs, When Applying Attributes To Dynamic Classes
» should be discoverable through reflection
PersistentClassInfoTypeBuilder specs, When Associating 1 DynamicType With 1 Existent
» should create 2 types In Current domain
PersistentClassInfoTypeBuilder specs, When Changing A Dynamic property
» should raize changed event
PersistentClassInfoTypeBuilder specs, When Dynamic Type Inherits Existent Type
» should have as base Class the existent one
PersistentClassInfoTypeBuilder specs, When Dynamic Type inherits a Dynamic type
» should have as base class the dynamic one
PersistentClassInfoTypeBuilder specs, When DynamicType Implement An Interface
» should be Discoverable thourgh reflection
» should create non existent properties
PersistentClassInfoTypeBuilder specs, When Creating Types In A Non Xaf Context
» should create a Dynamic Type
XpoObjectMerger, When Merging Dynamic Types
» should updateXpdictionary Schema for each type
» should call an update sql statement
» should create an ObjectType Column to Parent
36 passed, 0 failed, 1 skipped, took 9,59 seconds (MSpec).

What do you think of the above specs? Can you understand all functionality supported by the dynamics types module (WorldCreator) from the above specs?

Want to see some code for the spec “When Creating A reference Property of dynamic type”?

image
Is that descriptive or what?
I suggest you use TestDriven.Net to run your specs since it provides support debugging and TypeMock out of the box
And some more mspec goodies from @agross.
Download A fully working app covered with mspec for your reference

Subscribe to XAF feed
Subscribe to community feed

DiggIt!
blog comments powered by Disqus