c# - ADO.Net Mocking Context Generator Interface Problem -


i'm working ef 4 , repository pattern. in adventures in trying unit test ef data context, came across ado.net mocking context generator template, name describes, aids in mocking data context.

while context build fine, i'm having problems repository , it's bit of mystery. here repository interface (abbreviated):

 public interface irepository<t> t : class {     /// <summary>     /// finds entities     /// </summary>     /// <returns></returns>     iqueryable<t> find();      /// <summary>     /// find alls entities , loads included relational properties.     /// </summary>     /// <param name="includes">relational properties load.</param>     /// <returns></returns>     iqueryable<t> find(params expression<func<t, object>>[] includes);      /// <summary>     /// adds entity repository.     /// </summary>     /// <param name="entity">entity add.</param>     void add(t entity);      /// <summary>     /// updates entity in repository.     /// </summary>     /// <param name="entity">entity update.</param>     void update(t entity)...etc 

with mock context, new set of generated entities virtual properties. have given entities same namespace real entities purpose of mocking them , identical types real ones reference mock entities.

the problem when have implementation of repository interface interface not implemented exceptions, though in fact implementing interface. occurs when try build project. intellisense thinks fine (ie, no litte arrow under interface telling me need implement it).

below implementation of interface via icategorylocalized interface (it inherits irepository).

public class categorylocalizedrepository : mockdatabaserepository, icategorylocalizedrepository {     #region constructor      public categorylocalizedrepository(mockcontext context)         : base(context)     {     }      #endregion      #region data methods      public iqueryable<categorylocalized> find()     {         return context.categorylocalized;     }      public iqueryable<categorylocalized> find(params expression<func<categorylocalized, object>>[] includes)     {         return createobjectquery<categorylocalized>(context.categorylocalized, includes);     }      public categorylocalized get(int id)     {         return context.categorylocalized.singleordefault(d => d.categorylocalizedid == id);     }      public categorylocalized get(int id, params expression<func<categorylocalized, object>>[] includes)     {         iobjectset<categorylocalized> query = createobjectquery<categorylocalized>(context.categorylocalized, includes);         return query.singleordefault(d => d.categorylocalizedid == id);     }      public void add(categorylocalized categorylocal)     {         addentity<categorylocalized>(context.categorylocalized, categorylocal);     }      public void update(categorylocalized categorylocal)     {         updateentity<categorylocalized>(context.categorylocalized, categorylocal);     }...etc 

i don't know why compiler saying interface (irepository) not implemented in categorylocalizedrepository when is.

turns out had reference set of entities in repository , reference different set in mock data project.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -