TDD
-
I have a c# assembly, that will be passed to another developer to use as a dll. The other developer does not need to know the workings of the dll, so most of the classes are marked as internal. I have a few public classes that are exposed externally. Now, i want to add some tests to the assembly (I know they should have been done first!!), but if i add another project to the solution, the test project cannot see the internal classes, so i cant write the tests. How do i get round this without making the classes public, which i dont want to do? tia Mark ps, hope this is in the right forum, was not sure if it was here or vs :rolleyes:
-
I have a c# assembly, that will be passed to another developer to use as a dll. The other developer does not need to know the workings of the dll, so most of the classes are marked as internal. I have a few public classes that are exposed externally. Now, i want to add some tests to the assembly (I know they should have been done first!!), but if i add another project to the solution, the test project cannot see the internal classes, so i cant write the tests. How do i get round this without making the classes public, which i dont want to do? tia Mark ps, hope this is in the right forum, was not sure if it was here or vs :rolleyes:
In .NET 2, you can mark assemblies as [assembly:InternalsVisibleTo("assemblyname...")], so you could use this to tell the assemblies to show internal assemblies to test application.
Deja View - the feeling that you've seen this post before.
-
In .NET 2, you can mark assemblies as [assembly:InternalsVisibleTo("assemblyname...")], so you could use this to tell the assemblies to show internal assemblies to test application.
Deja View - the feeling that you've seen this post before.
:-D :-D :-D :-D :-D Thanks I assume that if a developer that was using this dll, called there project "Tests" for example, they would see everthing as well. Not really a problem as I dont think they would call it Tests. Maybe I should call my test project something obscure
-
:-D :-D :-D :-D :-D Thanks I assume that if a developer that was using this dll, called there project "Tests" for example, they would see everthing as well. Not really a problem as I dont think they would call it Tests. Maybe I should call my test project something obscure
You can use the public key of your unit test assembly in there as well, so it becomes
[assembly: InternalsVisibleTo("mytestproject, PublicKey="32de3ba45e0a00a1")]
Deja View - the feeling that you've seen this post before.
-
You can use the public key of your unit test assembly in there as well, so it becomes
[assembly: InternalsVisibleTo("mytestproject, PublicKey="32de3ba45e0a00a1")]
Deja View - the feeling that you've seen this post before.
Just saw this on twitter. I thought you'd be interested: HeadGeek Approving Community Credit submissions for this month. Looks like Peter O' Hanlon has just moved into the lead. http://tinyurl.com/6ce4ur[^] 25 minutes ago from web Well done! Keep up the good work.
Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog
-
You can use the public key of your unit test assembly in there as well, so it becomes
[assembly: InternalsVisibleTo("mytestproject, PublicKey="32de3ba45e0a00a1")]
Deja View - the feeling that you've seen this post before.
-
Just saw this on twitter. I thought you'd be interested: HeadGeek Approving Community Credit submissions for this month. Looks like Peter O' Hanlon has just moved into the lead. http://tinyurl.com/6ce4ur[^] 25 minutes ago from web Well done! Keep up the good work.
Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog
Cheers. It's been a busy couple of months blogging for me. It's helped working alongside Karl Shifflett - he's a coding/article writing machine, and has spurred me on.
Deja View - the feeling that you've seen this post before.
-
Cheers. It's been a busy couple of months blogging for me. It's helped working alongside Karl Shifflett - he's a coding/article writing machine, and has spurred me on.
Deja View - the feeling that you've seen this post before.
Pete O'Hanlon wrote:
It's helped working alongside Karl Shifflett
Indeed - We almost managed to get him along to Developer Day Scotland earlier this year.
Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog
-
Use sn -Tp on the test dll. This depends on you having strong named the test project of course.
Deja View - the feeling that you've seen this post before.
-
Use sn -Tp on the test dll. This depends on you having strong named the test project of course.
Deja View - the feeling that you've seen this post before.
-
Thanks, I have just done some reading and am working it out. I think i need to look into strong names more, but you have given me enought to work with. Thanks for your help, its appreciated Mark
Good man.
Deja View - the feeling that you've seen this post before.
-
Thanks, I have just done some reading and am working it out. I think i need to look into strong names more, but you have given me enought to work with. Thanks for your help, its appreciated Mark
If only everybody were as polite as you... :)
Cheers, Vıkram.
"You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.
-
If only everybody were as polite as you... :)
Cheers, Vıkram.
"You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.
I always 5 the people who take the time to offer thanks.
Deja View - the feeling that you've seen this post before.
-
If only everybody were as polite as you... :)
Cheers, Vıkram.
"You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.
Being polite costs nothing. As a member of a number of (coding/car/RC Helicopter) forums I see no end of rudeness. When others try and help (even if they cant solve your problem), they have taken their time to try, why not be polite and say thanks just my 2p worth :) Mark