<commit_before>﻿using System;
using System.IO;
using System.Threading;
using Mapsui.Geometries;
using Mapsui.Layers;
using Mapsui.Providers;
using Mapsui.Tests.Common.Maps;
using NUnit.Framework;
using SkiaSharp;
using Mapsui.Extensions;
using Mapsui.Rendering.Skia.Tests.Extensions;

namespace Mapsui.Rendering.Skia.Tests
{
    [TestFixture, Apartment(ApartmentState.STA)]
    class MapRendererTests
    {
        [Test]
        public void RenderPointsWithVectorStyle()
        {
            // arrange
            var map = VectorStyleSample.CreateMap();
            var viewport = map.Envelope.ToViewport(200, 4);
            const string fileName = "vector_symbol.png";

            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(viewport, map.Layers, map.BackColor);

            // aside
            File.WriteToGeneratedFolder(fileName, bitmap);

            // assert
            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap, 1, 0.99));
        }

        [Test]
        public void RenderPointWithBitmapSymbols()
        {
            // arrange
            var map = BitmapSymbolSample.CreateMap();
            var viewport = map.Envelope.ToViewport(200, 4);
            const string fileName = "points_with_symbolstyle.png";

            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(viewport, map.Layers, map.BackColor);

            // aside
            File.WriteToGeneratedFolder(fileName, bitmap);

            // assert
            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap, 1, 0.99));
        }

        [Test]
        public void RenderPointWithBitmapSymbolsInCollection()
        {
            // arrange
            var map = BitmapSymbolSample.CreateMap();
            var features = ((MemoryProvider<IGeometryFeature>)((MemoryLayer)map.Layers[0]).DataSource).Features;
            foreach (IGeometryFeature feature in features)
            {
                if (feature.Geometry is Geometry geometry)
                {
                    var collection = new GeometryCollection();
                    collection.Collection.Add(geometry);
                    feature.Geometry = collection;
                }
            }
            var viewport = map.Envelope.ToViewport(200, 4);
            const string fileName = "points_with_symbolstyle.png";<commit_msg>Run code cleanup on mapsui.Rendering.Skia.Tests<commit_after>﻿using System;
using System.IO;
using System.Threading;
using Mapsui.Geometries;
using Mapsui.Layers;
using Mapsui.Providers;
using Mapsui.Rendering.Skia.Tests.Extensions;
using Mapsui.Tests.Common.Maps;
using NUnit.Framework;
using SkiaSharp;

namespace Mapsui.Rendering.Skia.Tests
{
    [TestFixture, Apartment(ApartmentState.STA)]
    internal class MapRendererTests
    {
        [Test]
        public void RenderPointsWithVectorStyle()
        {
            // arrange
            var map = VectorStyleSample.CreateMap();
            var viewport = map.Envelope.ToViewport(200, 4);
            const string fileName = "vector_symbol.png";

            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(viewport, map.Layers, map.BackColor);

            // aside
            File.WriteToGeneratedFolder(fileName, bitmap);

            // assert
            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap, 1, 0.99));
        }

        [Test]
        public void RenderPointWithBitmapSymbols()
        {
            // arrange
            var map = BitmapSymbolSample.CreateMap();
            var viewport = map.Envelope.ToViewport(200, 4);
            const string fileName = "points_with_symbolstyle.png";

            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(viewport, map.Layers, map.BackColor);

            // aside
            File.WriteToGeneratedFolder(fileName, bitmap);

            // assert
            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap, 1, 0.99));
        }

        [Test]
        public void RenderPointWithBitmapSymbolsInCollection()
        {
            // arrange
            var map = BitmapSymbolSample.CreateMap();
            var features = ((MemoryProvider<IGeometryFeature>)((MemoryLayer)map.Layers[0]).DataSource).Features;
            foreach (var feature in features)
            {
                if (feature.Geometry is Geometry geometry)
                {
                    var collection = new GeometryCollection();
                    collection.Collection.Add(geometry);
                    feature.Geometry = collection;
                }
            }
            var viewport = map.Envelope.ToViewport(200, 4);
            const string fileName = "points_with_symbolstyle.png";
{'fraction_non_alphanumeric': 0.0927663122785074, 'fraction_numerical': 0.008755472170106316, 'mean_word_length': 2.059948979591837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4507279', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1230, 'n_words': 254}