﻿using Autofac.Extras.Common.Drawing;
using Autofac.Extras.Common.IO;
using Autofac.Extras.Common.Types;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace x.UnitTest.Drawing
{
    [TestClass]
    public class GraphicsUtilTest
    {
        [TestMethod]
        public void test_fromFile()
        {
            var filePath = Path.Combine(PathUtil.GetBaseDirectory(), "favicon.png");

            byte[] data = GraphicsUtil.toBytes(Image.FromFile(filePath));
            var saveFilePath = Path.Combine(
                PathUtil.GetBaseDirectory(),
                $"{DateTimeUtil.toFormat_yyyyMMddHHmmss()}{data.GetHashCode()}.png"
            );
            GraphicsUtil.write(saveFilePath, data);

            Assert.IsNotNull(data);
        }
    }
}
