Exemplo n.º 1
0
        public async Task TelemetryParser_UpdateData_Failure()
        {
            var  telemetryParser = new TelemetryParser(dataFetcherFailure, new CSVDataSaver());
            bool result          = await telemetryParser.UpdateData();

            Assert.AreEqual(false, result);
        }
Exemplo n.º 2
0
        public async Task TelemetryParser_ParseNumericValues()
        {
            IKernel kernel = new StandardKernel();

            kernel.Bind <IDataFetcher>().To <MockDataFetcher>();
            kernel.Bind <IDataSaver>().To <CSVDataSaver>();
            IDataFetcher dataFetcher     = kernel.Get <IDataFetcher>();
            IDataSaver   dataSaver       = kernel.Get <IDataSaver>();
            var          telemetryParser = new TelemetryParser(dataFetcher, dataSaver);
            await telemetryParser.UpdateData();

            var actualValues          = telemetryParser.FetchNumericData();
            var expectedNumericValues = new Dictionary <string, double>()
            {
                { "Humidity", 40 },
                { "Pressure", 1000 },
                { "Light_intensity", 0 },
                { "No_of_lamps", 1 },
                { "Temperature", 25 },
                { "No_of_airfans", 0 },
                { "No_of_heaters", 0 }
            };

            CollectionAssert.AreEquivalent(expectedNumericValues, actualValues);
        }
Exemplo n.º 3
0
        public async Task TelemetryParser_ParseTimestamp_Failure()
        {
            var telemetryParser = new TelemetryParser(dataFetcherFailure, new CSVDataSaver());
            await telemetryParser.UpdateData();

            Assert.AreEqual(null, await telemetryParser.GetTimestamp());
        }
Exemplo n.º 4
0
        public async Task TelemetryParser_UpdateData_Success()
        {
            IKernel kernel = new StandardKernel();

            kernel.Bind <IDataFetcher>().To <MockDataFetcher>();
            kernel.Bind <IDataSaver>().To <CSVDataSaver>();
            IDataFetcher dataFetcher = kernel.Get <IDataFetcher>();
            IDataSaver   dataSaver   = kernel.Get <IDataSaver>();

            var telemetryParser = new TelemetryParser(dataFetcher, dataSaver);

            bool result = await telemetryParser.UpdateData();

            Assert.AreEqual(true, result);
        }
Exemplo n.º 5
0
        public async Task TelemetryParser_ParseNumericValues_Failure()
        {
            var telemetryParser = new TelemetryParser(dataFetcherFailure, new CSVDataSaver());
            await telemetryParser.UpdateData();

            var expectedNumericValues = new Dictionary <string, double>()
            {
                { "Humidity", 0 },
                { "Pressure", 0 },
                { "Light_intensity", 0 },
                { "No_of_lamps", 0 },
                { "Temperature", 0 },
                { "No_of_airfans", 0 },
                { "No_of_heaters", 0 }
            };

            CollectionAssert.AreEquivalent(expectedNumericValues, telemetryParser.FetchNumericData());
        }
Exemplo n.º 6
0
        public async Task TelemetryParser_ParseTimestamp()
        {
            IKernel kernel = new StandardKernel();

            kernel.Bind <IDataFetcher>().To <MockDataFetcher>();
            kernel.Bind <IDataSaver>().To <CSVDataSaver>();
            IDataFetcher dataFetcher = kernel.Get <IDataFetcher>();
            IDataSaver   dataSaver   = kernel.Get <IDataSaver>();

            var telemetryParser = new TelemetryParser(dataFetcher, dataSaver);

            await telemetryParser.UpdateData();

            var actualDate = await telemetryParser.GetTimestamp();

            var expectedDate = new DateTime(2020, 5, 31, 15, 05, 17);

            Assert.AreEqual(expectedDate, actualDate);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var fileName     = "sampleTelemetry.json";
            var matchDetails = TelemetryParser.ParseTelemetry(fileName);
            var popularGun   = matchDetails.Players.SelectMany(x => x.PlayerKills).Select(x => x.DamageCauser).GroupBy(x => x).OrderByDescending(gp => gp.Count()).Select(x => x.Key).First();

            Console.WriteLine("Map: {0}", matchDetails.MapName);
            Console.WriteLine("Match Started At: {0}", matchDetails.MatchStartTime);
            Console.WriteLine("Match Ended At: {0}", matchDetails.MatchEndTime);
            Console.WriteLine("Total Match Length: {0} minutes", matchDetails.MatchLength.TotalMinutes);
            Console.WriteLine("Most Popular Gun: {0}", popularGun);
            PubgConfiguration.Configure((settings) =>
            {
                settings.ApiKey = "API KEY HERE";
            });
            var playerService = new PubgPlayerService();
            var playerTask    = playerService.FilterPlayersById(PUBGTelemetryParser.Enums.PubgRegion.PcNorthAmerica, "account.b34d58ce76d5459daf24991532333f30");

            playerTask.Wait();
            var result = playerTask.Result;
        }