//Test for the data available with last zero speed value
        public void ShouldYieldCorrectValuesWithLastZeroSpeedPeriod()
        {
            var expectedResult = new HistoryAnalysis
            {
                AnalysedDuration = new TimeSpan(2, 30, 0),
                DriverRating     = 0.1500m
            };

            var data = new[]
            {
                new Period
                {
                    Start        = new DateTimeOffset(2016, 10, 13, 17, 30, 0, TimeSpan.Zero),
                    End          = new DateTimeOffset(2016, 10, 13, 20, 00, 0, TimeSpan.Zero),
                    AverageSpeed = 30m
                },
                new Period
                {
                    Start        = new DateTimeOffset(2016, 10, 13, 20, 0, 0, TimeSpan.Zero),
                    End          = new DateTimeOffset(2016, 10, 13, 21, 30, 0, TimeSpan.Zero),
                    AverageSpeed = 0m
                }
            };

            var actualResult = new FormulaOneAnalyser().Analyse(data, false);

            Assert.That(actualResult.AnalysedDuration, Is.EqualTo(expectedResult.AnalysedDuration));
            Assert.That(actualResult.DriverRating, Is.EqualTo(expectedResult.DriverRating).Within(0.001m));
        }
        //Test for the data overlap before start time & speed more than limit
        public void ShouldYieldCorrectValuesWithFirstLastZeroSpeedAboveLimitWithPenalise()
        {
            var expectedResult = new HistoryAnalysis
            {
                AnalysedDuration = new TimeSpan(2, 00, 0),
                DriverRating     = 0.5m
            };

            var data = new[]
            {
                new Period
                {
                    Start        = new DateTimeOffset(2016, 10, 13, 3, 0, 0, TimeSpan.Zero),
                    End          = new DateTimeOffset(2016, 10, 13, 5, 0, 0, TimeSpan.Zero),
                    AverageSpeed = 0m
                },
                new Period
                {
                    Start        = new DateTimeOffset(2016, 10, 13, 5, 0, 0, TimeSpan.Zero),
                    End          = new DateTimeOffset(2016, 10, 13, 7, 0, 0, TimeSpan.Zero),
                    AverageSpeed = 250m
                },
                new Period
                {
                    Start        = new DateTimeOffset(2016, 10, 13, 8, 0, 0, TimeSpan.Zero),
                    End          = new DateTimeOffset(2016, 10, 13, 8, 30, 0, TimeSpan.Zero),
                    AverageSpeed = 0m
                }
            };

            var actualResult = new FormulaOneAnalyser().Analyse(data, true);

            Assert.That(actualResult.AnalysedDuration, Is.EqualTo(expectedResult.AnalysedDuration));
            Assert.That(actualResult.DriverRating, Is.EqualTo(expectedResult.DriverRating).Within(0.001m));
        }
 public void Initialize()
 {
     analyser = new FormulaOneAnalyser(new AnalyserConfiguration()
     {
         MaxSpeed = 200m, RatingForExceedingMaxSpeed = 1, PenaltyForFaultyRecording = 0.5m
     });
 }
Ejemplo n.º 4
0
 public void Initialize()
 {
     formulaOneAnalyser = new FormulaOneAnalyser(new DriverAnalysisCriteria
     {
         AllowedStartTime             = new TimeSpan(0, 0, 0),
         AllowedEndTime               = new TimeSpan(0, 0, 0),
         AllowedMaxSpeed              = 200m,
         RatingForExceedingSpeedLimit = 1,
     });
 }
        public void ShouldYieldCorrectValues()
        {
            var expectedResult = new HistoryAnalysis
            {
                AnalysedDuration = new TimeSpan(10, 3, 0),
                DriverRating     = 0.1231m
            };

            var actualResult = new FormulaOneAnalyser().Analyse(CannedDrivingData.History);

            Assert.That(actualResult.AnalysedDuration, Is.EqualTo(expectedResult.AnalysedDuration));
            Assert.That(actualResult.DriverRating, Is.EqualTo(expectedResult.DriverRating).Within(0.001m));
        }
        // Test to get correct values for the canned data with Penalise flag true
        public void ShouldYieldCorrectValuesForNullDataWithPenalise()
        {
            var expectedResult = new HistoryAnalysis
            {
                AnalysedDuration = new TimeSpan(0, 0, 0),
                DriverRating     = 0m
            };

            var actualResult = new FormulaOneAnalyser().Analyse(null, true);

            Assert.That(actualResult.AnalysedDuration, Is.EqualTo(expectedResult.AnalysedDuration));
            Assert.That(actualResult.DriverRating, Is.EqualTo(expectedResult.DriverRating).Within(0.001m));
        }
        //Test for the full period and full speed
        public void ShouldYieldCorrectValuesForFullPeriodSpeedWithPenalise()
        {
            var expectedResult = new HistoryAnalysis
            {
                AnalysedDuration = new TimeSpan(1, 0, 0),
                DriverRating     = 0.5m
            };

            var data = new[]
            {
                new Period
                {
                    Start        = new DateTimeOffset(2016, 10, 13, 13, 0, 0, TimeSpan.Zero),
                    End          = new DateTimeOffset(2016, 10, 13, 14, 0, 0, TimeSpan.Zero),
                    AverageSpeed = 200m
                }
            };

            var actualResult = new FormulaOneAnalyser().Analyse(data, true);

            Assert.That(actualResult.AnalysedDuration, Is.EqualTo(expectedResult.AnalysedDuration));
            Assert.That(actualResult.DriverRating, Is.EqualTo(expectedResult.DriverRating).Within(0.001m));
        }
Ejemplo n.º 8
0
 public void TearDown()
 {
     formulaOneAnalyser = null;
 }