<commit_before>﻿/*  Copyright 2016 <NAME>
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/
using NUnit.Framework;
using Rhino.Mocks;

namespace FenixLib.Core.Tests.Image
{
    [TestFixture]
    class FormatConverterTests
    {
        private IGraphic stubGraphic1bpp;
        private IGraphic stubGraphic8bpp;
        private IGraphic stubGraphic16bpp;
        private IGraphic stubGraphic32bpp;

        [SetUp]
        public void SetUp ()
        {
            SetUpMonochromeStub ();
            SetUpIndexedStub ();
        }

        private void SetUpMonochromeStub()
        {
            // 10x3 1bpp data
            // 11111111 11xxxxx
            // 10000000 01xxxxx
            // 11111111 11xxxxx
            byte[] pixelData1bpp = new byte[6];
            pixelData1bpp[0] = 0xFF; pixelData1bpp[1] = 0x3 << 6;
            pixelData1bpp[2] = 0x1 << 7; pixelData1bpp[3] = 0x1 << 6;
            pixelData1bpp[4] = 0xFF; pixelData1bpp[5] = 0x3 << 6;

            stubGraphic1bpp = MockRepository.GenerateStub<IGraphic> ();
            stubGraphic1bpp.Stub ( x => x.PixelData ).Return ( pixelData1bpp );
            stubGraphic1bpp.Stub ( x => x.GraphicFormat ).Return ( GraphicFormat.Monochrome );
        }

        private void SetUpIndexedStub()
        {
            // 10x3 8bpp data
            // 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
            // 0xFF 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xFF
            // 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
            byte[] pixelData8bpp = new byte[30];
            for ( int i = 0 ; i < 10 ; i++ )
            {
                pixelData8bpp[i] = 0xFF;
                pixelData8bpp[29 - i] = 0xFF;
            }
            pixelData8bpp[10] = 0xFF;
            for ( int i = 11 ; i < 19 ; i++ )
            {
                pixelData8bpp[i] = 0x00;
            }
            pixelData8bpp[19] = 0xFF;
            // Palette colors
            Color[] colors = new Color[256];
            colors[0] = new Color ( 0, 0, 0 );
            colors[1] = new Color ( 255, 255, 255 );
            colors[2] = new Color ( 255, 0, 0 );
            colors[3] = new Color ( 0, 255, 0 );
            colors[4] = new Color ( 0, 0, 255 );
            stubGraphic8bpp = MockRepository.GenerateStub<IGraphic> ();
            stubGraphic8bpp.Stub ( x => x.PixelData ).Return ( pixelData8bpp );
            stubGraphic8bpp.Stub ( x => x.Palette ).Return ( Palette.Create ( colors ) );
            stubGraphic8bpp.Stub ( x => x.GraphicFormat ).Return ( GraphicFormat.RgbIndexedPalette );
        }

        private void SetUp16bppStub()
        {
            ushort[,] pixelData = new ushort[10, 3];
            for (int i = 0 ; i < pixelData.GetLength(0) ; i++ )
            {
                for (int j = 0 ; j < pixelData.GetLength(1) ; i ++ )
                {
                    if ( i == 0 || i == 3 || j == 0 || j == 9 )
                        pixelData[i, j] = 0xFFFF;
                    else
                        pixelData[i, j] = 0x00;
                }
            }
        }

        [Test]
        public void Convert_MonochromeToIndexed_CheckFormat ()
        {

        }
        [Test]
        public void Convert_MonochromeTo16bpp_CheckFormat ()<commit_msg>Changes to accept new operator for Palette object construction.<commit_after>﻿/*  Copyright 2016 <NAME>
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/
using NUnit.Framework;
using Rhino.Mocks;

namespace FenixLib.Core.Tests.Image
{
    [TestFixture]
    class FormatConverterTests
    {
        private IGraphic stubGraphic1bpp;
        private IGraphic stubGraphic8bpp;
        private IGraphic stubGraphic16bpp;
        private IGraphic stubGraphic32bpp;

        [SetUp]
        public void SetUp ()
        {
            SetUpMonochromeStub ();
            SetUpIndexedStub ();
        }

        private void SetUpMonochromeStub()
        {
            // 10x3 1bpp data
            // 11111111 11xxxxx
            // 10000000 01xxxxx
            // 11111111 11xxxxx
            byte[] pixelData1bpp = new byte[6];
            pixelData1bpp[0] = 0xFF; pixelData1bpp[1] = 0x3 << 6;
            pixelData1bpp[2] = 0x1 << 7; pixelData1bpp[3] = 0x1 << 6;
            pixelData1bpp[4] = 0xFF; pixelData1bpp[5] = 0x3 << 6;

            stubGraphic1bpp = MockRepository.GenerateStub<IGraphic> ();
            stubGraphic1bpp.Stub ( x => x.PixelData ).Return ( pixelData1bpp );
            stubGraphic1bpp.Stub ( x => x.GraphicFormat ).Return ( GraphicFormat.Monochrome );
        }

        private void SetUpIndexedStub()
        {
            // 10x3 8bpp data
            // 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
            // 0xFF 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xFF
            // 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
            byte[] pixelData8bpp = new byte[30];
            for ( int i = 0 ; i < 10 ; i++ )
            {
                pixelData8bpp[i] = 0xFF;
                pixelData8bpp[29 - i] = 0xFF;
            }
            pixelData8bpp[10] = 0xFF;
            for ( int i = 11 ; i < 19 ; i++ )
            {
                pixelData8bpp[i] = 0x00;
            }
            pixelData8bpp[19] = 0xFF;
            // Palette colors
            Color[] colors = new Color[256];
            colors[0] = new Color ( 0, 0, 0 );
            colors[1] = new Color ( 255, 255, 255 );
            colors[2] = new Color ( 255, 0, 0 );
            colors[3] = new Color ( 0, 255, 0 );
            colors[4] = new Color ( 0, 0, 255 );
            stubGraphic8bpp = MockRepository.GenerateStub<IGraphic> ();
            stubGraphic8bpp.Stub ( x => x.PixelData ).Return ( pixelData8bpp );
            stubGraphic8bpp.Stub ( x => x.Palette ).Return ( new Palette ( colors ) );
            stubGraphic8bpp.Stub ( x => x.GraphicFormat ).Return ( GraphicFormat.RgbIndexedPalette );
        }

        private void SetUp16bppStub()
        {
            ushort[,] pixelData = new ushort[10, 3];
            for (int i = 0 ; i < pixelData.GetLength(0) ; i++ )
            {
                for (int j = 0 ; j < pixelData.GetLength(1) ; i ++ )
                {
                    if ( i == 0 || i == 3 || j == 0 || j == 9 )
                        pixelData[i, j] = 0xFFFF;
                    else
                        pixelData[i, j] = 0x00;
                }
            }
        }

        [Test]
        public void Convert_MonochromeToIndexed_CheckFormat ()
        {

        }
        [Test]
        public void Convert_MonochromeTo16bpp_CheckFormat ()
{'fraction_non_alphanumeric': 0.09824838667193468, 'fraction_numerical': 0.05715790860002634, 'mean_word_length': 1.6608269096005606, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4154430', 'n_tokens_mistral': 2645, 'n_tokens_neox': 2356, 'n_words': 645}