GetDateTime() public method

Returns a DateTime that contains the value of the specified variable.
public GetDateTime ( string name, string format, System.DateTime defaultValue ) : System.DateTime
name string The name of the variable to be read.
format string The expected format of the variable's value
defaultValue System.DateTime The value to be returned if returns null.
return System.DateTime
コード例 #1
0
        public void GetDateTime()
        {
            VariableAccessor va = new VariableAccessor(_testVariableSource);

            Assert.AreEqual(TESTDATETIME, va.GetDateTime("ValidDateTime", null, TESTDATETIME_DEFAULT));
            Assert.AreEqual(TESTDATETIME.ToUniversalTime(), va.GetDateTime("ValidDateTimeUtcRoundtripFormatted", "u", TESTDATETIME_DEFAULT));
            Assert.AreEqual(TESTDATETIME_DEFAULT, va.GetDateTime("InvalidDateTime", null, TESTDATETIME_DEFAULT, false));
            Assert.Throws <FormatException>(() => va.GetDateTime("InvalidDateTime", null, TESTDATETIME_DEFAULT, true));
        }
コード例 #2
0
 public void GetDateTime()
 {
     VariableAccessor va = new VariableAccessor(_testVariableSource);
     Assert.AreEqual(TESTDATETIME, va.GetDateTime("ValidDateTime", null, TESTDATETIME_DEFAULT));
     Assert.AreEqual(TESTDATETIME.ToUniversalTime(), va.GetDateTime("ValidDateTimeUtcRoundtripFormatted", "u", TESTDATETIME_DEFAULT));
     Assert.AreEqual(TESTDATETIME_DEFAULT, va.GetDateTime("InvalidDateTime", null, TESTDATETIME_DEFAULT, false));
     Assert.Throws<FormatException>(() => va.GetDateTime("InvalidDateTime", null, TESTDATETIME_DEFAULT, true));
 }