I am trying both xunit and TestDriven.Net for testing, for database using SQL CE4. Here is the entity definition:
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);
}
}
And here is the test method:
[Fact]
public void WhenProductAddedItShouldPersist()
{
var product= ObjectMother.Single<Product>();
productRepository.Add(product);
unitOfWork.Commit();
Assert.NotNull(productRepository.One(product.Id));
}
XUnit passes the method while TestDriven fails with the message - 'System.NotSupportedException : Default values not supported'.
Surprisingly- if I add another property to the entity (e.g. ProductName), TestDriven also pass. Could anyone give me some clue why this is happening?