By default unit tests will not have access to private members of the class. However this can be done with the help of Reflection. VSTS has a class PrivateObject which can help you do this. This class does all the required plumbing and gives you a straight forward approach to deal with this problem.
Following are the steps to use the PrivateObject class.
1. Instantiate the PrivateObject class by providing the “typeof” class to be tested. The best place to do this is the TestInitialize method.
2. Now you can access the private field of the class using the GetField method on the PrivateObject instance.
3. Similarly you can test the private method of the class using the Invoke method of the PrivateObject. This can be best done in a separate test method.
In a similar way you can access the static-private members of your test class using the PrivateType class
Thursday, April 24, 2008
Back-up of the Team Foundation Server Data
You can refer to the Microsoft guidelines at http://msdn2.microsoft.com/en-us/library/ms253070(vs.80).aspx for back-up steps of the team foundation server (TFS) data
Wednesday, April 16, 2008
How to apply SAME Code Analysis rules to different visual studio projects
Pretty Simple.
1. Using a text editor, open the project file (.csproj, .vbproj, etc) of the project whose rules are to copied into another project.
2. Copy the section <CodeAnalysisRules>.......... </CodeAnalysisRules> from that file.
3. Using a text editor, open the project file (.csproj, .vbproj, etc) of the project INTO whom the rules are to be copied.
4. Replace the<CodeAnalysisRules> .......... </CodeAnalysisRules> section of this file by the information copied from the earlier project.
5. In case you don't see a<CodeAnalysisRules> .......... </CodeAnalysisRules> section insert the copied stuff as the last element in the <PropertyGroup Condition=" '$(Configuration)$(Platform)' == 'ReleaseAnyCPU' "> element block.
1. Using a text editor, open the project file (.csproj, .vbproj, etc) of the project whose rules are to copied into another project.
2. Copy the section <CodeAnalysisRules>
3. Using a text editor, open the project file (.csproj, .vbproj, etc) of the project INTO whom the rules are to be copied.
4. Replace the
5. In case you don't see a
Solution for "Code Analysis Tab not visible in Visual Studio"
Try this simple solution before you try to fix this problem by reinstalling the IDE
>> Rename the file C:\WINDOWS\system32\msxml6.dll to C:\WINDOWS\system32\msxml6.dll.tmp
If this does not work you can try uninstalling and re-installing your IDE
>> Rename the file C:\WINDOWS\system32\msxml6.dll to C:\WINDOWS\system32\msxml6.dll.tmp
If this does not work you can try uninstalling and re-installing your IDE
Installing TFS 2008
Installing TFS 2008 is much more straight forward and less error prone as compared to installing TFS 2005.
The latest version of TFS 2008 installtion guide can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=ff12844f-398c-4fe9-8b0d-9e84181d9923&displaylang=en
The latest version of TFS 2008 installtion guide can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=ff12844f-398c-4fe9-8b0d-9e84181d9923&displaylang=en
Subscribe to:
Posts (Atom)