entity framework - Using Moq with EntityFramework graphdiff -


i have added graphdiff in existing entity framework solution utilizing moq framework testing. tests using moq in insert , update methods failing since method _context.updategraph throws following exception: system.nullreferenceexception: object reference not set instance of object. graphdiff on github https://github.com/refactorthis/graphdiff

updategraph extension method: https://github.com/refactorthis/graphdiff/blob/develop/graphdiff/graphdiff/dbcontextextensions.cs

how should hookup moq graphdiff?

we had problem well. how solved it.

so in icontext interface:

t updategraph<t>(t entity, expression<func<iupdateconfiguration<t>, object>> mapping = null) t : class, new();  dbentityentry<tentity> entry<tentity>(tentity entity) tentity : class;         dbentityentry entry(object entity);          dbcontextconfiguration configuration { get; } 

this in base context:

 public virtual t updategraph<t>(t entity, expression<func<iupdateconfiguration<t>, object>> mapping = null) t : class, new()         {             return null;         } 

and

private objectcontext objectcontext         {             { return (this iobjectcontextadapter).objectcontext; }         } 

and in actual concrete context:

public override t updategraph<t>(t entity, expression<func<iupdateconfiguration<t>, object>> mapping = null) // t : class, new()         {             return dbcontextextensions.updategraph<t>(this, entity, mapping);         } 

and

private objectcontext objectcontext         {             { return (this iobjectcontextadapter).objectcontext; }         } 

Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -