public void TestSimpleFormatOfDateTime() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); Assert.That(date.Evaluate(_model), Is.EqualTo("02/03/2001 04:05")); }
public void TestSimpleFormatOfDateTimeOnlyDate() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.Type = new MockAttribute(new Constant(DateType.Date.ToString())); Assert.That(date.Evaluate(_model), Is.EqualTo("02/03/2001")); }
public void TestEmpty() { var date = new FormatDate(); Assert.That(date.Evaluate(_model), Is.EqualTo(String.Empty)); }
public void TestSimpleFormatOfWithCustomPattern() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.Pattern = new MockAttribute(new Constant("dd MMM yyyy'T'HH:mm")); Assert.That(date.Evaluate(_model), Is.EqualTo("03 Feb 2001T04:05")); }
public void TestSimpleFormatOfWithCustomPatternWithTimeZone() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.Pattern = new MockAttribute(new Constant("HH:mm zzz")); Assert.That(date.Evaluate(_model), Is.EqualTo("04:05 +01:00")); }
public void TestSimpleFormatOfWithBothLongFormat() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Long.ToString())); date.DateStyle = new MockAttribute(new Constant(DateStyle.Long.ToString())); Assert.That(date.Evaluate(_model), Is.EqualTo("Saturday, 03 February 2001 04:05:06")); }
public void TestSimpleFormatOfWithBothLongFormatPatternOverride() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Long.ToString())); date.DateStyle = new MockAttribute(new Constant(DateStyle.Long.ToString())); date.Pattern = new MockAttribute(new Constant("dd MMM yyyy'T'HH:mm")); Assert.That(date.Evaluate(_model), Is.EqualTo("03 Feb 2001T04:05")); }
public void TestSimpleFormatOfString() { var date = new FormatDate(); date.Value = new MockAttribute(new Constant("1/6/2008 12:00:00")); Assert.That(date.Evaluate(_model), Is.EqualTo("01/06/2008 12:00")); }
public void TestSimpleFormatOfEmptyString() { var date = new FormatDate(); date.Value = new MockAttribute(new Constant("")); Assert.That(date.Evaluate(_model), Is.EqualTo(String.Empty)); }
public void TestSimpleFormatOfDifferentTimeStyle_ShortDifferentCulture() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 14, 5, 6); _model.Page[FormatConstants.LOCALE] = new CultureInfo("nl-NL"); date.Value = new MockAttribute(new Property("DateValue")); date.Type = new MockAttribute(new Constant(DateType.Time.ToString())); date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Short.ToString())); Assert.That(date.Evaluate(_model), Is.EqualTo("14:05")); }
public void TestSimpleFormatOfDifferentTimeStyle_Long() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.Type = new MockAttribute(new Constant(DateType.Time.ToString())); date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Long.ToString())); Assert.That(date.Evaluate(_model), Is.EqualTo("04:05:06")); }
public void TestSimpleFormatOfDifferentDateStyle_Wrong() { var date = new FormatDate(); _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6); date.Value = new MockAttribute(new Property("DateValue")); date.Type = new MockAttribute(new Constant(DateType.Date.ToString())); date.DateStyle = new MockAttribute(new Constant("Wrong")); try { date.Evaluate(_model); Assert.Fail("Expected failure"); } catch (ArgumentException Ae) { Assert.That(Ae.Message.Contains("Wrong")); } }