This week my team upgraded our solutions to Visual Studio 2010 and .Net framework 4. When we ran the tests of one our projects, one of our tests failed with a weird reason. The code is simple:public DateTime CreateDateWithGivenTime(string time)
{
[ExpectedException(typeof(OverflowException))]
public void CreateDateWithGivenTime_HoursNotInRange_ThrowOverflowException()
{
Testing on a branch before the conversion – the test passed.Debugging the code in both cases showed different behavior of the framework:Framework 3.5: Throws exceptionFramework 4: Code recovers and parses the string as if “77” is days, “11” is hours etc…
{
var t = TimeSpan.Parse(time);}The test was:[Test]
...
[ExpectedException(typeof(OverflowException))]
public void CreateDateWithGivenTime_HoursNotInRange_ThrowOverflowException()
{
CreateDateWithGivenTime("77:11:00");}
Testing on a branch before the conversion – the test passed.Debugging the code in both cases showed different behavior of the framework:Framework 3.5: Throws exceptionFramework 4: Code recovers and parses the string as if “77” is days, “11” is hours etc…
Read more: YsA.net
0 comments:
Post a Comment