using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper8.Skyscraper.Scraper.Storage;

namespace skyscraper8.Tests;

[TestClass]
public class CapturedTests : Feyllure
{
    [TestMethod]
    public void RussianT2Mi()
    {
        FileStream streamSample = GetStreamSample("express_3928L_t2mi.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //42931 uncovered
    }

    [TestMethod]
    public void Simmin()
    {
        FileStream streamSample = GetStreamSample("thor_11049v_simmin-radiomidun.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //36611 uncovered
    }

    [TestMethod]
    public void GseDab()
    {
        FileStream streamSample = GetStreamSample("thor_10717v_gse-dab.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //36446 uncovered
    }

    [TestMethod]
    public void SouthAmericanNip()
    {
        FileStream streamSample = GetStreamSample("argentinian-dvb-nip-000000.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //35222
    }

    [TestMethod]
    public void GseNip()
    {
        FileStream streamSample = GetStreamSample("astra1_12441v_gse-nip.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //34545
    }

    [TestMethod]
    public void GseNip2()
    {
        FileStream streamSample = GetStreamSample("astra1_11141h_gse_nip.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //34462
    }

    [TestMethod]
    public void TsNipIncludingLegacyChannel()
    {
        FileStream streamSample = GetStreamSample("hotbird_12380v_nip.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //33518
    }

    [TestMethod]
    public void TsNip()
    {
        FileStream streamSample = GetStreamSample("hotbird_12226v_nip.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //33518
    }

    [TestMethod]
    public void GseRcs2()
    {
        FileStream streamSample = GetStreamSample("telstar12v-bfbs-000000.ts");
        ProcessSample(streamSample);
        streamSample.Close();
        //32559
    }

    [TestMethod]
    public void BadrDvbSis()
    {
        FileStream streamSample = GetStreamSample("badr_12563v_dvb-sis.ts");
        ProcessSample(streamSample);
        streamSample.Close();
    }

    [TestMethod]
    public void Eutelsat5DvbSis()
    {
        FileStream streamSample = GetStreamSample("eutelsat5_12522v_dvb-sis.ts");
        ProcessSample(streamSample);
        streamSample.Close();
    }



    private void ProcessSample(Stream sample)
    {
        TsContext ts = new TsContext();
        
        InMemoryScraperStorageFactory inMemoryStorageFactory = new InMemoryScraperStorageFactory();
        DataStorage dataStorage = inMemoryStorageFactory.CreateDataStorage();
        
        NullObjectStorage nullObjectStorage = new NullObjectStorage();

        SkyscraperContext context = new SkyscraperContext(ts, dataStorage, nullObjectStorage);
        context.InitalizeFilterChain();
        context.IngestFromStream(sample);
    }
}
