コード例 #1
0
        public void NoDigitInString()
        {
            string dummystring = "This is a unit test of extractor class";


            Assert.AreEqual(0, uut.ExtractFromString(dummystring));
        }
コード例 #2
0
        public async Task <IEnumerable <Heatmap> > GetAllHeatmapAsync()
        {
            // Call asynchronous network methods in a try/catch block to handle exceptions.
            try
            {
                HeatClient.DefaultRequestHeaders.Add("ApiKey", "829320-adajdasd-12vasdas-baslk3"); //Server side API Token

                var handler = _httpHandler.Get("https://fruitflywebapi.azurewebsites.net/api/Heatmap", HeatClient).EnsureSuccessStatusCode();

                if (handler.IsSuccessStatusCode)
                {
                    var responseBody = await handler.Content.ReadAsStringAsync();

                    Console.WriteLine("Connection established");

                    //Splits the responsebody into each datatype and it's value. Items * 1000 to make sure that a thousand heatmapID's can be loaded.
                    var _line = responseBody.Split(',', items * 1000);

                    //Checks for 3 specific strings that contain: 'x', 'y' and ('h', 'e', 'a' and 't').
                    CheckEachString.CheckStringHeatmap(_line, LineX, LineY, LineHeat);

                    for (int i = 0; i < LineHeat.Count; i++)
                    {
                        //Here a new object of heatmap is created for each heatmap ID in the database. The values are collected from the sepereate list of x, y and heatmapID.
                        var obj = new Heatmap
                        {
                            x         = Extractor.ExtractFromString(LineX[i]),
                            y         = Extractor.ExtractFromString(LineY[i]),
                            HeatmapID = Extractor.ExtractFromString(LineHeat[i]),
                            Value     = 1
                        };

                        //adds all the added heatmaps into a list of heatmaps.
                        Heatmaps.Add(obj);
                    }

                    //compares if there are more than 1 element with the same x and y coordinates. If so, the value of the item will increase with 1 pr matching elements.
                    CompareElements.CompareHeatmapValues(Heatmaps);
                }
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine("\nException Caught!");
                Console.WriteLine("Message :{0} ", e.Message);
            }

            //DeleteAllHeatmapAsync();

            //returns all data stored in the list of heatmaps to the GET method
            Console.WriteLine("All heatmap data stored");
            return(Heatmaps);
        }