Exemplo n.º 1
0
 public void ThereIsNoNegativeDuration()
 {
     using (mocks.Ordered)
     {
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(
             Return.Value(DateTime.Parse("2111-11-11 5:00:00")));
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(
             Return.Value(DateTime.Parse("2111-11-11 5:00:00.6")));
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(
             Return.Value(DateTime.Parse("2111-11-11 5:00:00.7")));
     }
     activity = new RunningActivity("first", mockTimeSystem);
     activity.Stop();
     activity = RunningActivity.After(activity, "second");
     Assert.AreEqual(TimeSpan.Parse("0:00:00"), activity.Duration);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Split running activity by comma and returns array of activities
 /// </summary>
 /// <returns>array of activities, created after split</returns>
 public RunningActivity[] SplitByComma()
 {
     string[]          names = Name.Split(',');
     RunningActivity[] next  = new RunningActivity[names.Length];
     if (names.Length > 0)
     {
         this.Name = names[0];
         TimeSpan totalDuration = this.duration;
         this.duration = TimeSpan.FromMilliseconds(totalDuration.TotalMilliseconds / names.Length);
         next[0]       = this;
         for (int i = 1; i < names.Length; i++)
         {
             next[i]           = RunningActivity.After(next[i - 1], names[i]);
             next[i].IsRunning = false;
             next[i].duration  = this.duration;
         }
     }
     return(next);
 }