unit testing - How to create a test for Fluent nHibernate conventions? -


I am creating one. I create some conventions like primary key, foreign key, and several-to-many tables I do

I want to be able to test these conventions in the memory database to see if I have coded these conventions correctly.

Currently, I'm such a Skyuelaiti setting N Heibrnet using in-memory database:

  Configuration configuration = NULL; Var Factory = FluLi.Configure () .Database (SQLType Configuration Standard.InMemory (.) ShowSQL ()). Mappings (M = & gt; {M. Fulent mappings. Adfremassankaf & lt; Dataleyr & gt; (); m. Fulent mappings. Consenshn. Adfrem Alaskaof and LT; Detalayr & gt; ();}) Kanupryog configuration (( C) => Configuration = C). BuilderSecurity (); Var session = factory. Open (); Var export = new schemaxport (configuration); Export.Execute (true, true, wrong, session. Connection, zero);  

I am making a test case, but I do not have a test of naming convention. How can I get some unit tests in conventions using the Visual Studio Test Project?

What I have done is not a test against the database, but test only the generated mapping. So for example I have a conference that says that all foreign keys are written as ID and I test it (I'm using XUnate and not, but hopefully you get this concept Can ...):

  [Facts] Public Zero AddDefaultConventions_ShouldNameMappingToForeinKeyCorrectly () {var Configuration = Flu. Confifeyr () Kdetabes (Msskyuel configuration. MSSql2008) mappings (M = & gt; {M. Fulent mapping. Consenshn. Add (new Kstmorenj Keannwyn ()); FluentMappings.Add & lt; TestClassMap & gt; (); m. Add Flame Mapping. & Lt; TestClass2Map & gt; ();}). Build Configuration (); Var typemapping = configuration Gate Classmapping (Typef (Test Class 2)); Var Properties = Typemapping. GetProperty ("parent"); Claim it. AQUAL ("ParentID", Property, Column Itater. First (). Text); } Private class test class {public virtual id id {receipt; Set; }} Private Class TestClass2 {Public Virtual Ent ID {get; Set; } Receive Public Virtual Test Class Generator; Set; }} Private Class Test Classmaps: Classplapps & lt; Test class & gt; {Public Test Clasmap () {ID (x = & gt; x.id); }} Private Class Test Class 2 Map: Classplapp & lt; Test class 2 & gt; {Public TestClass2Map () {id (x => x.id); Reference (x => x.Parent); }}  

Biteedblu it is to try to choose something that will not be too hard, just TestClass2 test against DB and make sure that no one has thrown no exception ... but I think That's the way I have shown it is easy and I believe that when mapping the FluentNibbernet can generate the right NHibernate, NHibernate can generate the right questions for me.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -