using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using skyscraper5.Mpeg2;

namespace skyscraper8.Tests.ResourceTests;

[TestClass]
public class GsType1SanityTest : Feyllure
{
    [TestMethod]
    public void CheckBfbsCrc()
    {
        byte[] blob = Resources1.Frame00001343_TSGS1_MIS000_SYNC001;
        MemoryStream ms = new MemoryStream(blob, false);
        bool result = DvbCrc32.ValidateCrc(ms, 0, (int)ms.Length);
        Assert.IsTrue(result);
        
        blob = Resources1.Frame00000008_TSGS1_MIS000_SYNC001;
        ms = new MemoryStream(blob, false);
        result = DvbCrc32.ValidateCrc(ms, 0, (int)ms.Length);
        Assert.IsTrue(result);
    }

    [TestMethod]
    public void CheckBfbsCrcSpan()
    {
        byte[] blob = Resources1.Frame00000012_TSGS1_MIS000_SYNC001;
        ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(blob);
        bool result = DvbCrc32.ValidateCrc(span);
        Assert.IsTrue(result);
    }
}