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

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -