Unit testing Fluent NHibernate单元测试固定长度字符字段

Unit testing Fluent NHibernate单元测试固定长度字符字段,unit-testing,fluent-nhibernate,Unit Testing,Fluent Nhibernate,我有一个单元测试失败了,我知道原因,但我不确定应该如何处理它。我有以下单元测试: new PersistenceSpecification<OrderLine>(session) .CheckProperty(x => x.Line, "1") .VerifyTheMappings(); 新的PersistenceSpecification(会话) .CheckProperty(x=>x.行,“1”) .验证应用程序(); 它失败,出现以下错误:

我有一个单元测试失败了,我知道原因,但我不确定应该如何处理它。我有以下单元测试:

new PersistenceSpecification<OrderLine>(session)
       .CheckProperty(x => x.Line, "1")
       .VerifyTheMappings();
新的PersistenceSpecification(会话)
.CheckProperty(x=>x.行,“1”)
.验证应用程序();
它失败,出现以下错误:

测试方法CanCorrectlyMapOrderLine引发异常: System.ApplicationException:对于属性“Line”,应为“System.String”类型的“1”,但获得了“System.String”类型的“1”


它这样做的原因是因为x.Line指向数据库中的固定长度字符字段(准确地说是nchar(10)),当它插入数据时,它会用空格填充它。我应该在单元测试中指定“1”并在末尾加9个空格,还是应该在读入时以某种方式对其进行修剪?还有别的办法吗?

我最后只做了以下几点:

new PersistenceSpecification<OrderLine>(session)
   .CheckProperty(x => x.Line, "1".PadRight(10, ' '))
   .VerifyTheMappings();
新的PersistenceSpecification(会话)
.CheckProperty(x=>x.行,“1”.PadRight(10'))
.验证应用程序();