public Config CreateDefaultConfigObject() { Config conf = new Config(); // Default config values conf.retry.timeOut = 15; conf.retry.attempts = 5; conf.proxy = new Proxy(); conf.proxy.user = ""; conf.proxy.password = ""; conf.proxy.server = "automatic"; var siteini = new SiteIni("siteini", "channel_1"); var channel = new Channel(); channel.name = "Канал 1"; channel.xmltv_id = "Канал 1 ID"; channel.update = UpdateType.Incremental; channel.siteinis = new List <SiteIni>() { siteini }; conf.channels.Add(channel); var timeshifted = new Channel(); timeshifted.name = "Канал 1 +1"; timeshifted.xmltv_id = "Канал 1 +1 ID"; timeshifted.offset = 1; timeshifted.same_as = "Канал 1 ID"; channel.timeshifts = new List <Channel>(); channel.timeshifts.Add(timeshifted); channel = new Channel(); siteini = new SiteIni("siteiniCET", "channel_2"); channel.name = "Channel 2"; channel.xmltv_id = "Channel 2 ID"; channel.update = UpdateType.Incremental; channel.siteinis = new List <SiteIni>() { siteini }; conf.channels.Add(channel); channel = new Channel(); siteini = new SiteIni("siteini", "channel_3"); channel.name = "Channel 3"; channel.xmltv_id = "Channel 3 ID"; channel.update = UpdateType.Incremental; channel.siteinis = new List <SiteIni>() { siteini }; channel.include = "III"; channel.exclude = "EEE"; conf.channels.Add(channel); channel = new Channel(); channel.name = "Channel 4"; channel.xmltv_id = "Channel 4 ID"; channel.update = UpdateType.Incremental; channel.Enabled = false; conf.channels.Add(channel); return(conf); }
public void Run_Internal_JSON_Config_Test_Offset_Added_To_Parent_Channel() { var te = new TestEnvironment(ppType: PostProcessType.NONE); Arguments.grabingTempFolder = Path.Combine(Path.GetTempPath(), "wgmulti_tests"); Arguments.configDir = Arguments.grabingTempFolder; Arguments.webGrabFolder = Environment.GetEnvironmentVariable("wgpath"); Arguments.useJsonConfig = true; // Create new config and overwrite the wgmilti.config.json Config conf = new Config(); var siteini = new SiteIni("siteini", "channel_1"); var channel = new Channel(); channel.name = "Канал 1"; channel.xmltv_id = "Канал 1 ID"; channel.update = UpdateType.Incremental; channel.siteinis = new List <SiteIni>() { siteini }; channel.offset = 5.5; conf.channels.Add(channel); var timeshifted = new Channel(); timeshifted.name = "Канал 1 +1"; timeshifted.xmltv_id = "Канал 1 +1 ID"; timeshifted.offset = 1; timeshifted.same_as = "Канал 1 ID"; channel.timeshifts = new List <Channel>(); channel.timeshifts.Add(timeshifted); var content = conf.Serialize(true); File.WriteAllText(te.configFileJson, content); Application.Run(te.configFolder); var root = XDocument.Load(te.outputEpg); var tv = root.Element("tv"); Func <String, String> GetStartHour = delegate(String id) { try { return(tv.Elements("programme") .Where(p => p.Attribute("channel").Value .Equals(id)) .First().Attribute("start").Value.Substring(8, 4)); } catch { return(""); } }; // Select the start time of first program for 'Канал 1' and first program of 'Channel2ID' var time = GetStartHour(channel.xmltv_id); if (time != "0530") { Assert.Fail(String.Format("Start time of first program in channel {0} is {1}, 0500 was expected since channel has offset=5.5", channel.name, time)); } // Select the start time of first timeshifted program for 'Канал 1 +1' and first program of 'Channel2ID' time = GetStartHour(timeshifted.xmltv_id); if (time != "0630") { Assert.Fail(String.Format("Start time of first program in channel {0} is {1}, 0600 was expected since channel has offset=1 and the parent channel has offset=5.5", channel.name, time)); } }