开发者

FakeItEasy mock interface not found

开发者 https://www.devze.com 2023-02-25 14:45 出处:网络
I\'m new to FakeItEasy and mocking in general.I created a Visual Studio 2010 C# class library project.I added references to the NUnit DLL and the FakeItEasy DLL.I added \"using\" statements for both,

I'm new to FakeItEasy and mocking in general. I created a Visual Studio 2010 C# class library project. I added references to the NUnit DLL and the FakeItEasy DLL. I added "using" statements for both, then attempted to try some of the documentation examples. My code is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FakeItEasy.Core;
// ...
using NUnit.Framework;

namespace TestLib
{
    [TestFixture]
    public class Tester
    {
        [Test] 
        public void SomeTest() 
        {
            ISomething mockThing = A.Fake<ISomething>(); 
            /*
 开发者_如何学Python           ...
             */
        }

    }
}

I get errors "The type or namespace name 'ISomething' could not be found" and "The name 'A' does not exist in the current context."

What am I missing?


It turns out that it is necessary to create the interfaces that are referred to in the mocks. They are not auto-generated.

It is, however possible to specify additional interfaces to be implemented:

var foo = A.Fake<IFoo>(x => x.Implements(typeof(IComparable)).Implements(typeof(IFormattable))); 
0

精彩评论

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

关注公众号