开发者

MockUnitOfWork 'Cannot resolve symbol MockUnitOfWork'

开发者 https://www.devze.com 2022-12-18 04:08 出处:网络
I\'m trying to get Figure 3 Fake Database from IRepository using the example here http://msdn.microsoft.com/en-us/magazine/dd263069.aspx

I'm trying to get Figure 3 Fake Database from IRepository using the example here http://msdn.microsoft.com/en-us/magazine/dd263069.aspx

public class InMemoryRepository : IRepository
{
    private readonly Cache<Type, object> _types;
    private MockUnitOfWork _lastUnitOfWork;

    public InMemoryRepository()
    {
        _types = new 开发者_开发百科Cache<Type, object>(type =>
        {
            Type listType = typeof(List<>).MakeGenericType(type);
            return Activator.CreateInstance(listType);
        });
    }

    private IList<T> listFor<T>()
    {
        return (IList<T>)_types.Get(typeof(T));
    }

    public T Find<T>(long id) where T : Entity
    {
        return listFor<T>().FirstOrDefault(t => t.Id == id);
    }

    public void Delete<T>(T target)
    {
        listFor<T>().Remove(target);
    }

    public T[] Query<T>(Expression<Func<T, bool>> where)
    {
        var query = from item in listFor<T>() select item;
        return query.Where(where.Compile()).ToArray();
    }

    public void Save<T>(T target)
    {
        listFor<T>().Add(target);
    }
}

I'm getting 'Cannot resolve symbol MockUnitOfWork. I have NUnit/Moq/Rhino.Mock installed/referenced but I cannot find any reference to MockUnitOfWork. Any help appreciated.


You can just remove the MockUnitOfWork, because it is never used in the code.

I think it is a remnant left over after a refactoring.


The article doesn't explicitly say anything about what MockUnitOfWork is, but since it is an explicitly declared type, it must be a hand-rolled Mock.

Despite its semantic equivalence, it has nothing to do with Moq or RhinoMocks.

If you can download the source code for the article, I'm pretty sure you will find a class called MockUnitOfWork in the test project.

0

精彩评论

暂无评论...
验证码 换一张
取 消