I was trying to understand how to write unit tests for a few days now. I'm confused with following scenarios in the existing code.
In first function the max value changes depending on the object created at run time but in the second case it is a constant.
NOTE: The following functions are not related. These are two different scenarios.
SomeFunction1(arg1,....)
{
if(arg1 > someObject.MaxAllowedValue)
{
throw exception;
}
}
SomeFunction2(arg1,....)
{
if(arg1 > maxAllowedValue)
{
throw exception;
}
}
I am trying to test whether the function throws an exception when max value is exceeded.
Does the unit test remain the same in both the cases or is it different?
someObject
depends on the hardware, I'd follow DaveFar's advice and mock it.