예제 #1
0
 public void StopActivity()
 {
     Stub.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(startTime));
     activity = new RunningActivity("test activity", mockTimeSystem);
     Assert.IsTrue(activity.IsRunning);
     activity.Stop();
     Assert.IsFalse(activity.IsRunning);
 }
예제 #2
0
        public void SplitNames()
        {
            Stub.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(startTime));
            activity = new RunningActivity("first,second", mockTimeSystem);
            activity.Stop();
            RunningActivity second = activity.SplitByComma()[1];

            Assert.AreEqual("first", activity.Name);
            Assert.AreEqual("second", second.Name);
        }
예제 #3
0
 public void MillisecondsAreRounded()
 {
     using (mocks.Ordered)
     {
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("2007-11-18 5:00:00")));
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("2007-11-18 5:07:00.5")));
     }
     activity = new RunningActivity("activity", mockTimeSystem);
     activity.Stop();
     Assert.AreEqual(TimeSpan.Parse("0:07:01"), activity.Duration);
 }
예제 #4
0
 public void MillisecondsAreRounded()
 {
     using (mocks.Ordered)
     {
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("2007-11-18 5:00:00")));
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("2007-11-18 5:07:00.5")));
     }
     activity = new RunningActivity("activity", mockTimeSystem);
     activity.Stop();
     Assert.AreEqual(TimeSpan.Parse("0:07:01"), activity.Duration);
 }
예제 #5
0
 public void Split3()
 {
     using (mocks.Ordered)
     {
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("7:00:00")));
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("8:00:00")));
     }
     activity = new RunningActivity("first, second, third", mockTimeSystem);
     activity.Stop();
     RunningActivity third = activity.SplitByComma()[2];
     Assert.AreEqual(DateTime.Parse("7:40:00"), third.Start);
 }
예제 #6
0
        public void Split3()
        {
            using (mocks.Ordered)
            {
                Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("7:00:00")));
                Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("8:00:00")));
            }
            activity = new RunningActivity("first, second, third", mockTimeSystem);
            activity.Stop();
            RunningActivity third = activity.SplitByComma()[2];

            Assert.AreEqual(DateTime.Parse("7:40:00"), third.Start);
        }
예제 #7
0
        public void SplitTime()
        {
            using (mocks.Ordered)
            {
                Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("7:00:00")));
                Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("8:00:00")));
            }
            activity = new RunningActivity("first, second", mockTimeSystem);
            activity.Stop();
            RunningActivity second = activity.SplitByComma()[1];

            Assert.AreEqual(DateTime.Parse("7:00:00"), activity.Start);
            Assert.AreEqual(DateTime.Parse("7:30:00"), activity.End, "first end");
            Assert.AreEqual(DateTime.Parse("7:30:00"), second.Start, "second start");
            Assert.AreEqual(DateTime.Parse("8:00:00"), second.End);
        }
예제 #8
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);
 }
예제 #9
0
 public void SplitNames()
 {
     Stub.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(startTime));
     activity = new RunningActivity("first,second", mockTimeSystem);
     activity.Stop();
     RunningActivity second = activity.SplitByComma()[1];
     Assert.AreEqual("first", activity.Name);
     Assert.AreEqual("second", second.Name);
 }
예제 #10
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);
 }
예제 #11
0
 public void StopActivity()
 {
     Stub.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(startTime));
     activity = new RunningActivity("test activity",mockTimeSystem);
     Assert.IsTrue(activity.IsRunning);
     activity.Stop();
     Assert.IsFalse(activity.IsRunning);
 }
예제 #12
0
 public void SplitTime()
 {
     using (mocks.Ordered)
     {
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("7:00:00")));
         Expect.Once.On(mockTimeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("8:00:00")));
     }
     activity = new RunningActivity("first, second", mockTimeSystem);
     activity.Stop();
     RunningActivity second = activity.SplitByComma()[1];
     Assert.AreEqual(DateTime.Parse("7:00:00"), activity.Start);
     Assert.AreEqual(DateTime.Parse("7:30:00"), activity.End, "first end");
     Assert.AreEqual(DateTime.Parse("7:30:00"), second.Start, "second start");
     Assert.AreEqual(DateTime.Parse("8:00:00"), second.End);
 }