public void Execute_UtcToLocalWithCityName_Valid(object value, DateTime expected) { var function = new UtcToLocal(new LiteralScalarResolver <string>("Brussels")); var result = function.Evaluate(value); Assert.That(result, Is.EqualTo(expected)); }
public void Execute_TextToDateTimeAndUtcToLocal_Valid(string value, string format, string timeZone, DateTime expected) { var textToDateTime = new TextToDateTime(new LiteralScalarResolver <string>(format)); var utcToLocal = new UtcToLocal(new LiteralScalarResolver <string>(timeZone)); var result = utcToLocal.Evaluate(textToDateTime.Evaluate(value)); Assert.That(result, Is.EqualTo(expected)); Assert.That(((DateTime)result).Kind, Is.EqualTo(DateTimeKind.Unspecified)); }
public void ConvertingInvalidTypeReturnsUnsetValue() { // Arrange var conv = new UtcToLocal(); // Act var v = conv.Convert(string.Empty, null, null, null); // Assert Assert.AreEqual(DependencyProperty.UnsetValue, v); }
public void ConvertedValueIsInLocalTime() { // Arrange var conv = new UtcToLocal(); var nowUtc = DateTime.UtcNow; // Act var now = (DateTime)conv.Convert(nowUtc, null, null, null); // Assert Assert.AreNotEqual(DateTimeKind.Local, nowUtc.Kind); Assert.AreEqual(DateTimeKind.Local, now.Kind); }
public void ConvertBackReturnsUtcTime() { // Arrange var conv = new UtcToLocal(); var now = DateTime.Now; // Act var nowUtc = (DateTime)conv.ConvertBack(now, null, null, null); // Assert Assert.AreNotEqual(DateTimeKind.Utc, now.Kind); Assert.AreEqual(DateTimeKind.Utc, nowUtc.Kind); }