public void NullOrEmptyStringCanBeParsedAsTimeOffsetsObject() { ITimeOffsets parsed; Assert.IsFalse(TimeOffsets.TryParse(null, out parsed)); Assert.IsFalse(TimeOffsets.TryParse("", out parsed)); }
/// <summary> /// Add a time offset entry to the collection. /// </summary> /// <param name="newEntry">The entry to be added.</param> public static void AddEntry(TimeOffsetEntry newEntry) { foreach (TimeOffsetEntry oldEntry in TimeOffsets) { if (oldEntry.CountryCode == newEntry.CountryCode && oldEntry.Region == newEntry.Region) { return; } if (oldEntry.CountryCode == newEntry.CountryCode) { if (oldEntry.Region > newEntry.Region) { TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry); return; } } else { if (oldEntry.CountryCode.CompareTo(newEntry.CountryCode) > 0) { TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry); return; } } } TimeOffsets.Add(newEntry); }
void IViewModel.OnClosingDialog() { source.Annotation = annotation; if (TimeOffsets.TryParse(timeOffset, out var newTimeOffset)) { source.TimeOffsets = newTimeOffset; } }
void IViewEvents.OnClosingDialog() { source.Annotation = currentWindow.ReadControl(ControlFlag.AnnotationTextBox | ControlFlag.Value); ITimeOffsets newTimeOffset; if (TimeOffsets.TryParse(currentWindow.ReadControl(ControlFlag.TimeOffsetTextBox | ControlFlag.Value), out newTimeOffset)) { source.TimeOffsets = newTimeOffset; } }
void TestStringification() { var timeOffsets = init.ToTimeOffsets(); ITimeOffsets parsed; var str = timeOffsets.ToString(); Assert.IsTrue(TimeOffsets.TryParse(str, out parsed)); Assert.IsTrue(parsed.Equals(timeOffsets)); Assert.IsTrue(timeOffsets.Equals(parsed)); Assert.AreEqual(timeOffsets.GetHashCode(), parsed.GetHashCode()); }
public void TimeSpanCanBeParsedAsTimeOffsetsObject() { ITimeOffsets parsed; Assert.IsTrue(TimeOffsets.TryParse("00:00:00", out parsed)); Assert.AreEqual(TimeSpan.Zero, parsed.BaseOffset); Assert.IsTrue(TimeOffsets.TryParse("00:00:01", out parsed)); Assert.AreEqual(TimeSpan.FromSeconds(1), parsed.BaseOffset); Assert.IsTrue(TimeOffsets.TryParse("00:00:00.001", out parsed)); Assert.AreEqual(TimeSpan.FromMilliseconds(1), parsed.BaseOffset); }