I started to use Effort for unit testing.
Here is my code for initialization:
private IUnitOfWork unitOfWork;
[TestInitialize]
public void SetupTest()
{
DbConnection connection = Effort.DbConnectionFactory.CreateTransient();
var context = new STContext(connection);
context.Fakturas.Add(new Faktura { ID = 1, FakturaNo = 1000, OwnerID = 1 });
context.Fakturas.Add(new Faktura { ID = 2, FakturaNo = 1001, OwnerID = 1 });
context.Products.Add(new Product { ID = 1, Name = "ProductA", Price = 50 });
context.Products.Add(new Product { ID = 2, Name = "ProductB", Price = 100 });
context.Orders.Add(new Order { ID = 1, FakturaID = 1, ProductID = 1, Quantity = 1 });
context.Orders.Add(new Order { ID = 2, FakturaID = 2, ProductID = 1, Quantity = 1 });
unitOfWork = new UnitOfWork(context);
}
Then when I debug test I can see in debugger that those values from the code above are there, they are inserted in in-memory database, but fetching queries don't return them. Here is the image from debugger:
This is one of the queries which returns 0 elements return unitOfWork.Context.Products.ToList();
Anyone knows what might cause the problem?
Aucun commentaire:
Enregistrer un commentaire