[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Unit Testing for .Net application (C#)?

Posted on 2012-03-21
1
Medium Priority
?
417 Views
Last Modified: 2013-12-13
Hi,

Can you direct me to a good Unit Testing for c# tutorial site?

I am using the Visual Studio 2008/2010 for development.
What else do I need to do the Unit Testing?

I read a few simple tutorials but I still have many questions.
For an instance, this article uses pretty simple Person class as en example
http://www.dreamincode.net/forums/topic/108976-c%23-unit-testing-basics/

You have a get name, get age functions.

What if your methods are not simple, what they don't return anything.
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 37750823
The basis of unit testing is to see if a system returns the proper data.

Put at its simplest, you test a method by sending it different sets of data and then see if the result fits within the expected return value(s).

Methods that do not return anything usually do something.

The method might create a file. Then you aim is to test if the file is in the proper format. Then it is up to you to validate the resulting file and create an Assert according to the problems you might encounter. It might be as simple as comparing the resulting file with one containing what you are expecting, but it can be very involved if you want to test with different sets of data.

The method should write ot a database? Then you test method should read the database to see if the write did work. Something akind to the following:
bool expected = true;
bool result;

result = // Code that test for the presence of the expected data
Assert.AreEqual(expected, result, "Expected data not found in the database")

Open in new window

You did test against the expected result, even if it was not "returned" by your method.

If your method does not return anything or generate information somewhere, then what do you want to test? The flow of execution? How it reacts to users interaction? Then you are not doing unit testing and should use other techniques.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Curious about the latest ransomware attack? Check out our timeline of events surrounding the spread of this new virus along with tips on how to mitigate the damage.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Introduction to Processes
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This videā€¦

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question