Reputation: 4440
I'm currently trying to unit test an context class of the Entity Framework with the "Effort" framework (http://effort.codeplex.com/wikipage?title=Tutorials&referringTitle=Home).
This is how my test currently looks:
[TestMethod]
public void GetUseraccountsForRealTest()
{
DbConnection connection = Effort.DbConnectionFactory.CreateTransient();
SqlContext context = new SqlContext(connection);
context.TaskComment.Add(new TaskComment() { Id = 1, Message = "Test" });
}
The last line isn't working. Nothing happens.
This is how my SqlContext class looks:
public class SqlContext : DbContext
{
...
public IDbSet<TaskComment> TaskComment { get; set; }
...
//Constructor used by webserver
public SqlContext(string connectionString) : base(connectionString)
{
}
//Constructor used for unit testing
public SqlContext(DbConnection connection) : base(connection, true)
{
this.Configuration.LazyLoadingEnabled = false;
}
///
/// <param name="modelBuilder"></param>
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
}
}
Anyone got an idea how I can solve this problem? Don't have any experience with "Effort" and there's not too much documentation. :-(
Upvotes: 1
Views: 1044
Reputation: 4440
Solved the problem on my own. I didn't use IDbSet in my context, butt just DbSet which lead to some difficulties.
Upvotes: 1