Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. TDD

TDD

Scheduled Pinned Locked Moved C#
questioncsharpvisual-studiotesting
14 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mark_w_
    wrote on last edited by
    #1

    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:

    P 1 Reply Last reply
    0
    • M mark_w_

      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:

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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.

      My blog | My articles | MoXAML PowerToys

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        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.

        My blog | My articles | MoXAML PowerToys

        M Offline
        M Offline
        mark_w_
        wrote on last edited by
        #3

        :-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

        P 1 Reply Last reply
        0
        • M mark_w_

          :-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

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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.

          My blog | My articles | MoXAML PowerToys

          C M 2 Replies Last reply
          0
          • P Pete OHanlon

            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.

            My blog | My articles | MoXAML PowerToys

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            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

            P 1 Reply Last reply
            0
            • P Pete OHanlon

              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.

              My blog | My articles | MoXAML PowerToys

              M Offline
              M Offline
              mark_w_
              wrote on last edited by
              #6

              That sounds good, How do i find out what the publicKey of my test project is :confused:

              P 1 Reply Last reply
              0
              • C Colin Angus Mackay

                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

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                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.

                My blog | My articles | MoXAML PowerToys

                C 1 Reply Last reply
                0
                • P Pete OHanlon

                  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.

                  My blog | My articles | MoXAML PowerToys

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • M mark_w_

                    That sounds good, How do i find out what the publicKey of my test project is :confused:

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #9

                    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.

                    My blog | My articles | MoXAML PowerToys

                    M 1 Reply Last reply
                    0
                    • P Pete OHanlon

                      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.

                      My blog | My articles | MoXAML PowerToys

                      M Offline
                      M Offline
                      mark_w_
                      wrote on last edited by
                      #10

                      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

                      P V 2 Replies Last reply
                      0
                      • M mark_w_

                        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

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #11

                        Good man.

                        Deja View - the feeling that you've seen this post before.

                        My blog | My articles | MoXAML PowerToys

                        1 Reply Last reply
                        0
                        • M mark_w_

                          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

                          V Offline
                          V Offline
                          Vikram A Punathambekar
                          wrote on last edited by
                          #12

                          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.

                          P M 2 Replies Last reply
                          0
                          • V Vikram A Punathambekar

                            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.

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #13

                            I always 5 the people who take the time to offer thanks.

                            Deja View - the feeling that you've seen this post before.

                            My blog | My articles | MoXAML PowerToys

                            1 Reply Last reply
                            0
                            • V Vikram A Punathambekar

                              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.

                              M Offline
                              M Offline
                              mark_w_
                              wrote on last edited by
                              #14

                              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

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups