From: <exo...@us...> - 2006-05-31 05:23:27
|
Revision: 2434 Author: exortech Date: 2006-05-30 22:23:21 -0700 (Tue, 30 May 2006) ViewCVS: http://svn.sourceforge.net/ccnet/?rev=2434&view=rev Log Message: ----------- CCNET-696: improved parse error handling for DateLabeller Modified Paths: -------------- trunk/project/UnitTests/Core/Label/DateLabellerTest.cs trunk/project/core/label/DateLabeller.cs Modified: trunk/project/UnitTests/Core/Label/DateLabellerTest.cs =================================================================== --- trunk/project/UnitTests/Core/Label/DateLabellerTest.cs 2006-05-30 23:31:45 UTC (rev 2433) +++ trunk/project/UnitTests/Core/Label/DateLabellerTest.cs 2006-05-31 05:23:21 UTC (rev 2434) @@ -31,5 +31,11 @@ { Assert.AreEqual("2005.1.1.15", labeller.Generate(IntegrationResultMother.CreateSuccessful("2005.1.1.14"))); } + + [Test] + public void HandleInvalidLabel() + { + Assert.AreEqual("2005.1.1.1", labeller.Generate(IntegrationResultMother.CreateSuccessful("13"))); + } } } \ No newline at end of file Modified: trunk/project/core/label/DateLabeller.cs =================================================================== --- trunk/project/core/label/DateLabeller.cs 2006-05-30 23:31:45 UTC (rev 2433) +++ trunk/project/core/label/DateLabeller.cs 2006-05-31 05:23:21 UTC (rev 2434) @@ -22,8 +22,7 @@ { DateTime now = dateTimeProvider.Now; - Version version = resultFromLastBuild.IsInitial() - ? MakeDefaultVersion(now) : new Version(resultFromLastBuild.LastSuccessfulIntegrationLabel); + Version version = ParseVersion(now, resultFromLastBuild); int revision = version.Revision; if (now.Year == version.Major && now.Month == version.Minor && now.Day == version.Build) @@ -37,14 +36,21 @@ return new Version(now.Year, now.Month, now.Day, revision).ToString(); } - public void Run(IIntegrationResult result) + private Version ParseVersion(DateTime date, IIntegrationResult resultFromLastBuild) { - result.Label = Generate(result); + try + { + return new Version(resultFromLastBuild.LastSuccessfulIntegrationLabel); + } + catch (SystemException) + { + return new Version(date.Year, date.Month, date.Day, 0); + } } - private Version MakeDefaultVersion(DateTime date) + public void Run(IIntegrationResult result) { - return new Version(date.Year, date.Month, date.Day, 0); + result.Label = Generate(result); } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |