SQL CE4を使用したデータベースのテストでは、xunitとTestDriven.Netの両方を試しています。エンティティの定義は次のとおりです。
public class Product
{
private readonly ICollection<Inventory> inventories = new List<Inventory>();
private int id;
public virtual int Id { get; set; }
//public virtual string ProductName { get; set; }
public virtual ICollection<Inventory> Inventories
{
get { return inventories; }
}
}
public class ProductConfiguration : EntityTypeConfiguration<Product>
{
public ProductConfiguration()
{
HasKey(p => p.Id); //Id column of the product is an Identity column
Property(p => p.Id);
}
}
そしてここにテスト方法があります:
[Fact]
public void WhenProductAddedItShouldPersist()
{
var product= ObjectMother.Single<Product>();
productRepository.Add(product);
unitOfWork.Commit();
Assert.NotNull(productRepository.One(product.Id));
}
XUnitはメソッドを渡しますが、TestDrivenは次のメッセージで失敗します-'System.NotSupportedException:デフォルト値はサポートされていません'。
驚いたことに、エンティティに別のプロパティ(ProductNameなど)を追加すると、TestDrivenも合格します。なぜこれが起こっているのか誰かが私にいくつかの手がかりを与えることができますか?