Could anyone give me a guideline/walkthrough to add a test case from VS2010?

Hi there;

Could anyone give me a guideline/walkthrough to add a test case from VS2010?

As I had a sample application, I want to add that application to my real application. How to do this?

Regards.
LVL 12
jazzIIIloveAsked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:


http://msdn.microsoft.com/en-us/library/bb385974.aspx

This is explanation (llok also a little bit above it in the same link about testing internal methods through accessor)

When you create a unit test for an internal method in C# or for a friend method in Microsoft Visual Basic, a dialog box appears that allows you to choose between having your internal methods accessed with the private accessor or with the InternalsVisibleToAttribute.


If you choose to have your internal methods accessed with the InternalsVisibleToAttribute, the attribute is added to the AssemblyInfo.cs file. The attribute makes the internal methods in the code that you are testing available to the test project. A new attribute is added for each test project for which you choose this option.

If you choose to have your internal methods accessed with the private accessor, you see the same behavior as described earlier in this article for private methods: a Test References folder is added to your test project, an accessor is added to that folder, and the accessor is referred to in the logic of the unit test method. In this case, the private accessor provides access to both the internal and the private methods that you are testing.

If you have chosen to add the InternalsVisibleToAttribute to your project, you can still create unit tests for internal methods and have them accessed with the private accessor instead. However, you have to do this when you create the unit test. In the Create Unit Test dialog box, click Settings. In the Test Generation Settings dialog box, clear the Honor InternalsVisibleTo Attribute check box.
0
 
for_yanConnect With a Mentor Commented:
I'm not sure what you mean about adding a test case from VS2010 ?

Do you want some guidance on how to use VS2010 for C# ?
0
 
disruptConnect With a Mentor Commented:
See this page to create manual test cases

http://msdn.microsoft.com/en-us/library/dd286715.aspx
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
jazzIIIloveAuthor Commented:
for_yan:

yep.

Kind regards.
0
 
jazzIIIloveAuthor Commented:
ok, I got a problem, I am not sure whether to say Yes or No for the shot, I try to create unit test for my project and select it during the wizard but I end up with screen. So, what should I do?

Kind regards.
1.png
0
 
jazzIIIloveAuthor Commented:
>>The attribute makes the internal methods in the code that you are testing available to the test project.

Thanks.
0
 
jazzIIIloveAuthor Commented:
So; in fact, to be more clear, in plain english;

InternalsVisibleToAttribute means;

Internals [which are the members of a class in a C# application are] VisibleToAttribute [which is the test project having that Test attribute]

Is it true?

Regards.
0
 
for_yanConnect With a Mentor Commented:
Yes it is true.
But this applies not just to any members of the class, but to those methods which are declared internal - so they cannot be accessed
normally by other classes. So as I undersatdn there are two ways to test them - either with private accessors (see the same link above
http://msdn.microsoft.com/en-us/library/bb385974.aspx - the beginning of the page)  or with this visibleToAttribute.
0
 
jazzIIIloveAuthor Commented:
>> to those methods which are declared internal

E.g. a method that is in a referenced dll which is used by that C# application (not the test application I am taliking about).

Right?

or?

Kind regards.

0
 
for_yanConnect With a Mentor Commented:
No, this is about methods in your application, in your code.
Your test class would often be the oustide class for those methods
and you would not nortmally be able to execute internal methods  from outside class.
So this part is concerned with dealing with such situation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.