-
April 5th, 2011, 12:51 PM
#1
Question about C# unit tests
Hello!
I am relatively new to C# and I am currently working as a software QA at a .net shop. I'm interested in writing unit tests using the framework built into Visual Studio 2010 and I loosely followed this tutorial http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
Here is the code I am writing:
/// <summary>
///A test for LoginInfo Constructor
///</summary>
[TestMethod()]
public void LoginInfoConstructorTest()
{
string userId = "Username1";
string password = "Password1";
LoginInfo target = new LoginInfo(userId, password);
Assert.AreEqual<string>(userId, loginInfo.UserId,
"The UserId was not correctly initialized.");
}
When I write this, I receive an error that says "The name 'loginInfo' does not exist in the current context". I don't understand why it is telling me this when 'loginInfo' is defined in the code above. What am I doing wrong?
-
April 5th, 2011, 04:21 PM
#2
Re: Question about C# unit tests
You have not defined loginInfo. You have defined a variable called target of type LoginInfo.
At a guess, is your code meant to read...
Code:
Assert.AreEqual<string>(userId, target.UserId, "The UserId was not correctly initialized.");
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
April 5th, 2011, 06:08 PM
#3
Re: Question about C# unit tests
Inside your uinit test project, you'll need to add a reference to the code you are trying to test.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|