public void ArgbStringToColor_InputFFFFFFFF_ReturnWhite() { var input = "#FFFFFFFF"; var result = StringColorConverter.ArgbStringToColor(input); var expect = Color.FromArgb(255, 255, 255, 255); Assert.AreEqual(expect, result, $@"Returned color not as expected. Expected: {expect}, Actual: {result}"); }
/// <summary> /// Gets list of all map polygons stored in the database. /// </summary> /// <returns><b>List</b> containing <b>MapPolygonItem</b> objects populated with data from database.</returns> public static async Task <List <MapPolygonItem> > GetMapPolygonItemsAsync() { var result = new List <MapPolygonItem>(); using (var cnn = await GetDbConnectionAsync()) { cnn.Open(); var sqlcommand = @"SELECT m.Id, m.Name, m.StrokeColor, m.FillColor, l.Id, l.Name, g.Altitude, g.Latitude, g.Longitude FROM ((MapElement m INNER JOIN Layer l ON m.Layer_Id = l.Id) INNER JOIN Geoposition g ON m.Id = g.MapElement_Id) WHERE m.Type='MapPolygonItem'"; var anons = new List <TmpMapElementContainer>(); cnn.Query <dynamic, MapLayerItem, BasicGeoposition, int>(sqlcommand, (polyline, layer, pos) => { if (anons.Count == 0 || anons.Last().Id != polyline.Id) { anons.Add(new TmpMapElementContainer() { Id = (int)polyline.Id, Name = polyline.Name, StrokeColor = StringColorConverter.ArgbStringToColor((string)polyline.StrokeColor), FillColor = StringColorConverter.ArgbStringToColor((string)polyline.FillColor), Layer = layer }); } anons.Last().Path.Add(pos); return(0); }, splitOn: "Id,Altitude").ToList(); for (int i = 0; i < anons.Count; i++) { result.Add(MapElementItemFactoryService.GetMapPolygonItem(anons[i].Name, anons[i].Path, anons[i].Layer, anons[i].StrokeColor, anons[i].FillColor, anons[i].Id)); } } return(result); }