public override void PerformTest()
 {
     long startTime = new NativeDate().GetTime();
     long sum = 0;
     const long n = 2000000;
     for (int i = 0; i <= n; i++)
     {
         sum += i;
     }
     long deltaTime = new NativeDate().GetTime() - startTime;
     AssertEquals(((n / 2) * (n + 1)), sum);
     Log("Result is " + sum + ".  Took " + deltaTime.ToString() + "ms");
 }
예제 #2
0
 private string TimeSince(ISearchResultTweet tweet)
 {
     long tweetTime = NativeDate.Parse(tweet.CreatedAt);
     NativeDate now = new NativeDate();
     long deltaSeconds = (long)Math.Floor((now.GetTime() - tweetTime) / 1000);
     deltaSeconds += (now.GetTimezoneOffset() * 60);
     if (deltaSeconds < 60)
     {
         return "less than a minute ago";
     }
     else if (deltaSeconds < 120)
     {
         return "about a minute ago";
     }
     else if (deltaSeconds < (60 * 60))
     {
         return Math.Floor(deltaSeconds / 60).ToString() + " minutes ago";
     }
     else if (deltaSeconds < (120 * 60))
     {
         return "about an hour ago";
     }
     else if (deltaSeconds < (24 * 60 * 60))
     {
         return "about " + (Math.Floor(deltaSeconds / 3600)).ToString() + " hours ago";
     }
     else if (deltaSeconds < (48 * 60 * 60))
     {
         return "1 day ago";
     }
     else
     {
         return (Math.Floor(deltaSeconds / 86400)).ToString() + " days ago";
     }
 }
예제 #3
0
 private static void PerformTest(ITest test)
 {
     Log("Performing test: " + test.Name);
     long startTime = new NativeDate().GetTime();
     test.Test();
     long deltaTime = new NativeDate().GetTime() - startTime;
     if (test.Passed)
     {
         _passCount++;
         Log("Test: " + test.Name + " [PASSED]: " + deltaTime + " ms");
     }
     else
     {
         Log("Test: " + test.Name + " [FAILED]: " + deltaTime + " ms => " + test.Exception + " - " + test.Exception.StackTrace);
         _failures.Add(test);
     }
     // TODO: ConditionalExpression "test.Passsed?'PASSED':'FAILED'" was producing either "undefined" or "'FAILED'" need regression test for it
 }