public void IntegrationTest() { var fileName = Path.Combine(Path.GetTempPath(), string.Format("tmp{0}.xml", Environment.TickCount)); using (var stopWatch = new StopWatch(new FileSystemTimeTrackingRepository(fileName))) { Assert.AreEqual(0, stopWatch.GetLog().Length); Assert.AreEqual(null, stopWatch.GetCurrent()); stopWatch.Start(1); Assert.AreEqual(0, stopWatch.GetLog().Length); Assert.AreEqual(1, stopWatch.GetCurrent().AssignableID); } using (var stopWatch = new StopWatch(new FileSystemTimeTrackingRepository(fileName))) { Assert.AreEqual(0, stopWatch.GetLog().Length); Assert.AreEqual(1, stopWatch.GetCurrent().AssignableID); stopWatch.Stop("Done"); Assert.AreEqual(1, stopWatch.GetLog().Length); Assert.AreEqual(null, stopWatch.GetCurrent()); } using (var stopWatch = new StopWatch(new FileSystemTimeTrackingRepository(fileName))) { Assert.AreEqual(1, stopWatch.GetLog().Length); Assert.AreEqual(null, stopWatch.GetCurrent()); stopWatch.Start(2); Assert.AreEqual(1, stopWatch.GetLog().Length); Assert.AreEqual(2, stopWatch.GetCurrent().AssignableID); } using (var stopWatch = new StopWatch(new FileSystemTimeTrackingRepository(fileName))) { Assert.AreEqual(1, stopWatch.GetLog().Length); Assert.AreEqual(2, stopWatch.GetCurrent().AssignableID); stopWatch.Stop("Done"); Assert.AreEqual(2, stopWatch.GetLog().Length); Assert.AreEqual(null, stopWatch.GetCurrent()); } File.Delete(fileName); }
public void StartStop() { var stopWatch = new StopWatch(new DummyRepository()); Assert.AreEqual(0, stopWatch.GetLog().Length); stopWatch.Start(1); Assert.AreEqual(0, stopWatch.GetLog().Length); stopWatch.Start(1); Assert.AreEqual(1, stopWatch.GetLog().Length); stopWatch.Start(2); Assert.AreEqual(2, stopWatch.GetLog().Length); stopWatch.Stop("Done"); Assert.AreEqual(3, stopWatch.GetLog().Length); stopWatch.Delete(stopWatch.GetLog()[0]); Assert.AreEqual(2, stopWatch.GetLog().Length); stopWatch.Delete(stopWatch.GetLog()[0]); Assert.AreEqual(1, stopWatch.GetLog().Length); stopWatch.Delete(stopWatch.GetLog()[0]); Assert.AreEqual(0, stopWatch.GetLog().Length); }