开发者

Interfaces not showing up in Visual Studio Intellisense on Test Class

I am fairly new to development, and Visual Studio 2010.

I have a solution with a Test Project:

  • In my solution, there are two projects: "TPS" and "TPS.Tests"
  • In the TPS project, in the namespace "TPS.Models" I have defin开发者_运维知识库ed a bunch of classes, and two interfaces.
  • I have created a Test Class in the TPS.Tests project, and have added "using TPS.Models;"
  • I attempt to implement the interface by typing it out (e.g. public class FakeObjectClass : IObjectClass), but it isn't recognised (so I can't get the auto-implement going, which would be handy as I have over 100 methods)
  • Typing in the class, in Intellisense, I can see all the objects defined in my model, but none of the interfaces.

Google has been unusually silent on the search combinations I have tried. I am hoping there is some simple explanation/fix?

Thanks in advance for your time.

Tim.


If you haven't specified an access modifier when defining the Interface, it will default to internal and not be visible to other assemblies.

Make sure that you defined your interface as

public interface IMyInterface


A few things to check: - Does your "TPS.Tests" project have a reference to the "TPS" project? - Are your interfaces in the "TPS.Models" namespace? Putting the files in a sub-directory of the project, such as "Interfaces", can affect their namespace. - Are the interfaces marked as Public?

Also, I would suggest using an Isolation (aka "Mocking" framework) to create your fake objects, such as Moq, Rhino.Mocks, etc, rather than rolling your own fake objects for most situations.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜