开发者

Getting the Compiler Error CS0122 - 'member' is inaccessible due to its protection level - while trying to access a class in a different project

I am trying to get to grips with NUnit - i have installed it and run it successf开发者_开发问答ully within one project. I want to keep productioncode seperate from testcode, so i write tests in a different project. The Test Project Links to the original project. (IDE C# Express 2010)

My Testcode looks like this:

using NUnit.Framework;

namespace test.Import
{
    [TestFixture]
    class XMLOpenTest
    {
        [Test]
        public void openNotAPath(){
            try
            {
                production.Import.XMLHandler.open("Not A Path");
            }
            catch
            {
                Assert.Fail("File Open Fail");
            }
        }
    }
}

I know i could resolve this by making the production.Import.XMLHandler Class public, but i dont want to change my productioncode to allow this kind of testing.

How do i get around this? Can i make changes to my testcode? Are there other good ways to seperate test and production code in two projects? Are there ressources for dummys on the internet?


This is usually solved using InternalsVisibleToAttribute. See this and this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜