Example #1
0
        public void ShouldReturnCorrectFilenameForSvt1()
        {
            var fileInfo = ChannelInfoFile.FromSourceTypeAndDate(SourceType.Svt1Live, new DateTime(2017, 4, 20));

            Assert.AreEqual(SourceType.Svt1Live, fileInfo.Source);
            Assert.AreEqual("svt1.svt.se_2017-04-20.xml.gz", fileInfo.FileName);
        }
        private void ChannelInfoBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var fileInfo = ChannelInfoFile.FromSourceTypeAndDate(_type, Date);
            var loader   = new StreamDownloader();

            WebClient    wc      = new WebClient();
            MemoryStream stream  = new MemoryStream(wc.DownloadData(DbUrl + fileInfo.FileName));
            var          rawData = stream.ToArray();

            if (IsGZipHeader(rawData))
            {
                GZipStream   uncompressed = new GZipStream(stream, CompressionMode.Decompress);
                MemoryStream output       = new MemoryStream();
                uncompressed.CopyTo(output);

                var data      = output.ToArray();
                var xmlString = System.Text.Encoding.UTF8.GetString(data);
                Info = StringXmlSerializer.Deserialize <ChannelInfo>(xmlString);
            }
            else
            {
                wc.Encoding = System.Text.Encoding.UTF8;
                var xmlText = wc.DownloadString(DbUrl + fileInfo.FileName);
                Info = StringXmlSerializer.Deserialize <ChannelInfo>(xmlText);
            }

            Info.Type = _type;
        }
Example #3
0
        public void Setup()
        {
            var fileInfo = ChannelInfoFile.FromSourceTypeAndDate(SourceType.Svt1Live,
                                                                 new DateTime(2017, 4, 20));
            var      data = File.ReadAllBytes("ChannelData/" + fileInfo.FileName);
            Encoding ansi = Encoding.GetEncoding(1252);
            var      s    = ansi.GetString(data);

            underTest =
                StringXmlSerializer.Deserialize <ChannelInfo>(s);
        }