3

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も合格します。なぜこれが起こっているのか誰かが私にいくつかの手がかりを与えることができますか?

4

1 に答える 1

4

同じエラーが発生し、検索中にこれが見つかりました:http ://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/583c7839-22a4-460e-8665-3e5e3998a0d5

既知のバグのようです。

于 2012-02-04T02:51:18.480 に答える