unit testing - Fluent NHibernate PersistenceSpecification can't test a collection of strings -



unit testing - Fluent NHibernate PersistenceSpecification can't test a collection of strings -

i'm using fluent nhibernate map a class has collection of strings this:

public class foo { public virtual icollection<string> strings { get; set; } } public class foomap : classmap<foo> { public foomap() { hasmany(f => f.strings).element("somecolumnname"); } }

when write unit test using persistencespecification class included in fnh package, fails:

[testmethod] public void canmapcollectionofstrings() { var somestrings = new list<string> { "foo", "bar", "baz" }; new persistencespecification<foo>(currentsession) .checklist(x => x.strings, somestrings) // mappingexception .verifythemappings(); }

this test throws nhibernate.mappingexception: no persister for: system.string when calling checklist(). however, if seek persist object myself, works fine.

[testmethod] public void canpersistcollectionofstrings() { var foo = new foo { strings = new list<string> { "foo", "bar", "baz" }; }; currentsession.save(foo); currentsession.flush(); var savedfoo = currentsession.linq<foo>.first(); assert.areequal(3, savedfoo.strings.count()); // test passes }

why first unit test failing?

checkcomponentlist method right way in case:

var somestrings = new list<string> { "foo", "bar", "baz" }; new persistencespecification<foo>(currentsession) .checkcomponentlist(x => x.strings, somestrings) .verifythemappings();

this code work me (nh 3.1, fnh 1.2). hope help.

unit-testing nhibernate fluent-nhibernate

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -