static void Main(string[] args) { try { Config.Settings = Config.LoadFromExecutablePath(); VerifyConnectionString(); DatabaseCommand command = DatabaseCommand.Parse(args); Log.i(tag, command.Description()); System.Console.WriteLine("Using: " + Config.Settings.ConnectionString); Stopwatch sw = new Stopwatch(); sw.Start(); command.Execute(); var totalSeconds = sw.Elapsed.TotalSeconds; if (totalSeconds > 5) { Log.w(tag, "Wasted " + TimeSpanString.ToString(sw.Elapsed) + " on: " + command.Description()); } } catch (Exception caught) { System.Console.WriteLine(caught.Message); Log.e(tag, caught); Environment.Exit(1); } finally { Log.Flush(); } }
public void TickPrecisionTimeSpanTest() { DateTime dt = KnownTimeWithTicks; TimeSpan ts = KnownTimeWithTicks - new DateTime(2008, 1, 1); TimeSpanString val = new TimeSpanString { When = ts }, clone = Serializer.DeepClone(val); Assert.AreEqual(ts, clone.When); }
public void OneSecond() { var span = TimeSpanString.ToString(TimeSpan.FromSeconds(1)); Assert.AreEqual("1 second", span); }
public void AllParts() { var span = TimeSpanString.ToString(new TimeSpan(1, 2, 3, 4, 5)); Assert.AreEqual("1 day, 2 hours, 3 minutes, 4 seconds", span); }
public void OneDay2Seconds() { var span = TimeSpanString.ToString(new TimeSpan(1, 0, 0, 2)); Assert.AreEqual("1 day, 2 seconds", span); }
public void FourHours() { var span = TimeSpanString.ToString(TimeSpan.FromHours(4)); Assert.AreEqual("4 hours", span); }