开发者

Is it a good idea to test for id value while testing Fluent NHibernate mappings?

I'm working on tests for my Fluent NHibernate mappings, and my question is - is it a good idea to test for id value if Id column is represented by identity in Sql Server? Since it changes after each insert, how can I possibly do it?

            new PersistenceSpecification<Product>(session)
               .CheckProperty(p => p.Id, 1)
               .CheckProperty开发者_开发技巧(p => p.Name, "Awesome hat")
               .CheckProperty(p => p.Price, 9.90)
               .CheckList(p => p.StoresStockedIn, new List<Store>())
               .VerifyTheMappings();


I don't think it adds any value to the test. The PersistenceSpecification does an insert then selects the object by identifier. If the identifier isn't generated then the test will fail. You can easily verify this by temporarily changing the mapping to assigned or removing the identity setting on the database column.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜