I donโt know what you would call this unit test, but I strongly recommend that you avoid writing it because there is nothing on earth to make the statement fail. If the constructor succeeds, the CLR guarantees you a new instance that will not be empty.
Now, if the constructor of your object throws an exception in some circumstances, you can name it as follows:
[TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void Product_Constructor_ShouldThrowIfNullArgumentSupplied() { new Product(null); }
So, there are two possible cases for the code you are testing:
- You get a copy
- You get an exception
No need to check the first one.
source share