Possible Duplicate:
Unit testing void methods?
I need to write unit test cases for the GUI methods which does not return any value, how i can test the ac
Possible Duplicate:
Unit testing void methods?
I need to write unit test cases for the GUI methods which does not return any value, how i can test the ac
You can make sure it doesn't throw, at least by
Assert.DoesNotThrow<ExceptionType>( () => myClass.myMethod() );
However, bear in mind that a method that does not return a value, but does something, relies on side effects and therefore is not really amenable to unit testing, as you cannot test the whole state of a system in a unit test.
You can mock certain methods and classes that your method calls and assert that they are called. You can use some mocking framework for this purpose, most of them have the functionality to test: Assert.IsCalled();
You can also assert that the certain changes in environment that are expected are met. For example, a file is created.
If it does not throw an exception when passed correct values for params (if any), then it passes. If it throws the correct excpeptions when passed invalid values then it passes.