Exemple #1
0
        public void Runner_GetLapThreeLaps_ReturnValidLap()
        {
            //Arrange
            Runner newRunner   = new Runner();
            Lap    expectedLap = new Lap(4);
            Lap    actualLap;


            //Act
            newRunner.AddLap(new Lap(8));
            newRunner.AddLap(expectedLap);
            newRunner.AddLap(new Lap(12));
            actualLap = newRunner.GetLap(4);

            //Assert
            Assert.AreEqual(expectedLap, actualLap);
        }
Exemple #2
0
        public void Runner_GetLapThreeLaps_ReturnsException()
        {
            //Arrange
            Runner newRunner = new Runner();
            Lap    actualLap;

            //Act
            newRunner.AddLap(new Lap(1));
            newRunner.AddLap(new Lap(2));
            newRunner.AddLap(new Lap(3));

            //Assert
            try
            {
                actualLap = newRunner.GetLap(4);
            }
            catch (Exception e)
            {
                StringAssert.Contains(e.Message, "Lap was not found");
                return;
            }
            Assert.Fail("No exception was thrown.");
        }
Exemple #3
0
        public void Runner_GetLapSplitTime_ReturnsSplitTime()
        {
            //Arrange
            TimeSpan expectedTimeSpan = new TimeSpan(0, 1, 20, 15);
            TimeSpan actualTimeSpan;
            Runner   newRunner = new Runner();

            newRunner.AddLap(new Lap(4, ClockType.Split, 1, 20, 15F));

            //Act
            actualTimeSpan = newRunner.GetLap(4).SplitTime;

            //Assert
            Assert.AreEqual(expectedTimeSpan, actualTimeSpan);
        }
Exemple #4
0
        public void Runner_AddLapNegative_ReturnsException()
        {
            Runner newRunner = new Runner();

            try
            {
                newRunner.AddLap(new Lap(-1));
            }
            catch (Exception e)
            {
                StringAssert.Contains(e.Message, "Laps must be numbered greater than 0");
                return;
            }
            Assert.Fail("No exception was thrown");
        }