开发者

Unable to retrieve classes ttd

开发者 https://www.devze.com 2023-02-28 10:49 出处:网络
I have a asp website solution where i wish to add some unit tests. In the solution i have added a new test project.

I have a asp website solution where i wish to add some unit tests.

In the solution i have added a new test project.

All my C# classes are located in the folder called 'App_Code'.

But when i try to write Person p = new Person(); in my test class it cannot find the class Person.

Its my intention to make that object and fill it up with all sorts of things the p开发者_高级运维erson class holds (id, name etc).

//But i wish to directly acces Person, not PersonTest  
    PersonTest pt = new PersonTest();

                pt.IdTest = 1; //error method group only

How can i exactly put test date into the ID? Ms Test is pretty confusing compared to JUnit where everything seemed alot more straight forward.

Thanks.


Make sure you have the proper references setup to access your code. Right click on References in your Test project -> Add Reference -> Projects tab -> Choose the project where "Person" is.


Have you added the "using" directive? After adding the reference, you also either have to reference classes by namespace.class, or add a using personnamespace; at the top of the file.


I just had the same problem but in a winform project. In my case the answer was I had misspelt the namespace. As soon as I changed that it came up. Allen

0

精彩评论

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