Example #1
0
        public void GetLapTimes_ReturnAllDrivers_WhenRequested(string dir,
                                                               string driverFilePath,
                                                               string lapTimeFilePath,
                                                               InfrastructureDriver.RequestFactory driverRequestFactory,
                                                               InfrastructureDriver.ResponseMapper driverResponseMapper,
                                                               InfrastructureLap.RequestFactory lapTimeRequestFactory,
                                                               InfrastructureLap.ResponseMapper lapTimeResponseMapper,
                                                               int year,
                                                               int round)
        {
            var ergastDriverClient = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, driverFilePath);
            var driverClient       = new InfrastructureDriver.DriverClient(ergastDriverClient, driverRequestFactory, driverResponseMapper);

            var ergastLapTimeClient = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, lapTimeFilePath);
            var lapTimeClient       = new InfrastructureLap.LapTimeClient(ergastLapTimeClient, lapTimeRequestFactory, lapTimeResponseMapper);

            var lapRepository = new LapRepository(driverClient, lapTimeClient);

            var lapTimeDictionary = Task.Run(async() => await lapRepository.GetLapTimesAsync(year, round)).Result;

            Assert.NotNull(lapTimeDictionary);
            Assert.Equal(20, lapTimeDictionary.Keys.Count());

            var driversWithMoreThanOneLap = lapTimeDictionary.Where(x => x.Value.Count > 1).Select(x => x.Key).Distinct().Count();

            Assert.Equal(10, driversWithMoreThanOneLap);

            var hulkenbergLaps = lapTimeDictionary["HUL"].ToArray();

            Assert.NotNull(hulkenbergLaps);
            Assert.Equal(2, hulkenbergLaps.Length);
            Assert.Equal(9, hulkenbergLaps[0].Position);
            Assert.Equal(6, hulkenbergLaps[1].Position);
        }
        public void Testar_Instance()
        {
            //Arrange.

            //Act.
            LapRepository repository = new LapRepository(this.CreateContext());

            //Assert.
            Assert.IsNotNull(repository);
        }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();
            LapsRepository = new LapRepository();

            #region Notify

            MyNotifyIcon = new System.Windows.Forms.NotifyIcon();

            var dir = System.IO.Directory.GetParent(System.IO.Directory.GetParent(Environment.CurrentDirectory)
                                                    .ToString()) + "\\Resource\\stopwatch.ico";
            MyNotifyIcon.Icon              = new System.Drawing.Icon(dir);
            MyNotifyIcon.MouseDoubleClick += MyNotifyIcon_MouseDoubleClick;

            #endregion Notify

            dt.Tick    += dt_Tick;
            dt.Interval = new TimeSpan(0, 0, 0, 0, 1);
            dt.Start();
        }
Example #4
0
        static void Main(string[] args)
        {
            try
            {
                var path = Apresentation();

                var dataReceived = LoggerReport.ReceiveData(path);

                var lineResults = dataReceived.GetLineResults();

                var template = GetTemplate();

                ILapRepository lapRepository = new LapRepository(new FunRaceContext(lineResults));

                var addLapCommandHandler = FormulaOneCommand.Initializer(template, lapRepository);

                addLapCommandHandler.Handler();

                var lapQuery = LapQuery.Create(lapRepository);

                lapQuery.GetPositions();

                lapQuery.GetBestLap();

                lapQuery.GetAverageSpeed();

                lapQuery.GetDifferenceForEachDriver();

                lapQuery.GetBestLapOfEachDriver();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                throw;
            }
        }