static void Main()
    {
        StopWatch stopWatch = new StopWatch();

        Console.WriteLine("Hiii, Welcome To the StopWatch");
        Console.WriteLine("Start:");
        stopWatch.Start = 1;
        Console.WriteLine("Stop");
        stopWatch.Start = 1;
        stopWatch.Stop  = 1;

        stopWatch.Duration();
    }
Beispiel #2
0
        public void Duration_StopwatchStartedAndStopped_SecondsEqualDelayTime()
        {
            var random  = new Random();
            var seconds = random.Next(1, 5);

            var stopwatch = new StopWatch();

            stopwatch.Start();
            Thread.Sleep(seconds * 1000);
            stopwatch.Stop();

            Assert.AreEqual(seconds, stopwatch.Duration().Seconds);
        }