ROUTINE-LEVEL ON ERROR UNDO, THROW.

USING OpenEdge.Core.Assert FROM PROPATH.

CLASS unittests.gui.fillin.date.screen.DateParseTest
INHERITS unittests.gui.fillin.date.screen.DateParseTestBase:
    
   /**
    * Tests successful date string parse
    *
    * @param spec
    *        date string
    * @param expectedYear
    *        expected result year
    * @param expectedMonth
    *        expected result month
    * @param expectedDay
    *        expected result day
    */
    METHOD OVERRIDE VOID handleTestSuccess(
       INPUT spec AS CHARACTER,
       INPUT expectedYear AS INTEGER,
       INPUT expectedMonth AS INTEGER,
       INPUT expectedDay AS INTEGER):
       
       setScreenValue(spec).
       
       DEFINE VARIABLE d AS DATE NO-UNDO.
       d = getInputValue().
       
       Assert:Equals(expectedYear, YEAR(d)).
       Assert:Equals(expectedMonth, MONTH(d)).
       Assert:Equals(expectedDay, DAY(d)).
       
    END METHOD.
       
   /**
    * Tests successful date string parse to an unknown date value
    *
    * @param spec
    *        date string
    */
    METHOD OVERRIDE VOID handleTestUnknown(
       INPUT spec AS CHARACTER):
       setScreenValue(spec).
       
       DEFINE VARIABLE d AS DATE NO-UNDO.
       d = getInputValue().
       
       Assert:IsTrue(d = ?).
    END METHOD.

   /**
    * Tests date string parse failure
    *
    * @param spec
    *        date string
    * @param errorNo
    *        expected error number
    */
    METHOD OVERRIDE VOID handleTestFailure(
       INPUT spec AS CHARACTER,
       INPUT errorNo AS INTEGER):
       ERROR-STATUS:ERROR = FALSE.
       
       setScreenValue(spec) NO-ERROR.

       Assert:IsTrue(ERROR-STATUS:ERROR).
       Assert:Equals(errorNo, ERROR-STATUS:GET-NUMBER(1)).
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testToday():
       SUPER:testToday().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testNow():
       SUPER:testNow().
    END METHOD.
    
    @Test.
    METHOD PUBLIC OVERRIDE VOID testUnknownValues():
       SUPER:testUnknownValues().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testMdyFailures():
       SUPER:testMdyFailures().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testMdySuccesses():
       SUPER:testMdySuccesses().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testDmyFailures():
       SUPER:testDmyFailures().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testDmySuccesses():
       SUPER:testDmySuccesses().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testYmdFailures():
       SUPER:testYmdFailures().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testYmdSuccesses():
       SUPER:testYmdSuccesses().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testMydFailures():
       SUPER:testMydFailures().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testMydSuccesses():
       SUPER:testMydSuccesses().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testDymFailures():
       SUPER:testDymFailures().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testDymSuccesses():
       SUPER:testDymSuccesses().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testYdmFailures():
       SUPER:testYdmFailures().
    END METHOD.

    @Test.
    METHOD PUBLIC OVERRIDE VOID testYdmSuccesses():
       SUPER:testYdmSuccesses().
    END METHOD.

END CLASS.

