by Patrik Hägne via Legend and truth on 5/17/2009 10:45:00 PM
My first tests of classes are often tests that asserts that the constructor throws ArgumentNullException for null arguments, something like this:
[Test] public void constructor_throws_when_fileSystem_is_null() { Assert.Throws<ArgumentNullException>(() => { new TransactionalFileSystem((IFileSystem)null, this.transactionManager); }); }
As you see I explicitly cast the null value to the type of the parameter in the constructor signature, this is benefitial for two reasons:
Original Post: Cast null values in tests
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.