示例#1
0
        public void TestDefaultLanguage()
        {
            ConfigTools.InitConf("Config.xml");
            CultureInfo ci = ConfigTools.GetCurrentLanguage();

            Assert.AreEqual(ci, CultureInfo.CurrentCulture);
        }
示例#2
0
        public void TestDefaultLanguageChange()
        {
            CultureInfo ci = CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToUpper() == "FR" ? CultureInfo.GetCultureInfo("en") : CultureInfo.GetCultureInfo("de");

            ConfigTools.InitConf("Config.xml", ci);
            Assert.AreEqual(ci, ConfigTools.GetCurrentLanguage());
        }
示例#3
0
        public void TestAvailableLanguages()
        {
            ConfigTools.InitConf("Config.xml");
            ICollection <CultureInfo> languages = ConfigTools.GetAvailableLanguage();

            Assert.IsTrue(languages.Contains(CultureInfo.GetCultureInfo("en")));
            Assert.IsTrue(languages.Contains(CultureInfo.GetCultureInfo("fr")));
        }
示例#4
0
 public void VerifOverride()
 {
     ConfigTools.InitConf("Config_override.xml");
     Assert.AreEqual(Globale.OUTPUT_FOLDER, "outputFolder_override");
     Assert.IsFalse(Globale.INTERACTIVE_MODE);
     Assert.AreEqual(Globale.PUBLISHER, "publisher_override");
     Assert.AreEqual(Globale.DEFAULT_CHAPTER_TITLE, "defaultChapterTitle_override");
     Assert.AreEqual(Globale.MAX_CHAPTER_ON_ERROR_COUNT_BEFORE_STOP, 20);
 }
示例#5
0
        public static void Main(string[] args)
        {
            try
            {
                ConfigTools.InitConf("Config.xml");
                ConfigTools.InitConf("Config_user.xml");
                ConfigTools.InitLightNovels("LightNovels.xml", true);
                ConfigTools.InitLightNovels("LightNovels_user.xml", true);
                consoleTools = new ConsoleTools(1);
                ConsoleTools ctForWebcrawler = new ConsoleTools(3);
                webCrawler = new WebCrawler(ctForWebcrawler, ctForWebcrawler);
            }
            catch (ApplicationException e)
            {
                consoleTools.Log(e.Message);
                return;
            }

            if (!consoleTools.Ask(String.Format(LightNovelSniffer_CLI_Strings.AskOutputFolderConfirmation, Globale.OUTPUT_FOLDER)))
            {
                string folder = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskOutputFolder);
                if (!string.IsNullOrEmpty(folder))
                {
                    Globale.OUTPUT_FOLDER = folder;
                }
            }

            consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramStart);

            foreach (LnParameters ln in Globale.LN_TO_RETRIEVE)
            {
                if (consoleTools.Ask(string.Format(LightNovelSniffer_CLI_Strings.AskRetrieveLn, ln.name)))
                {
                    GetNovel(ln);
                }
            }

            if (Globale.INTERACTIVE_MODE && consoleTools.AskNegative(LightNovelSniffer_CLI_Strings.LogEndOfLnInConfig))
            {
                LnParameters ln;
                do
                {
                    ln = BuildDynamicLn();
                    GetNovel(ln);
                } while (!string.IsNullOrEmpty(ln.name));
            }

            consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramEnd);
            if (Globale.INTERACTIVE_MODE)
            {
                Console.ReadLine();
            }
        }
示例#6
0
 public void TestNullCultureInfo()
 {
     ConfigTools.InitConf("Config.xml");
     try
     {
         ConfigTools.SetLanguage((CultureInfo)null);
     }
     catch (LanguageException e)
     {
         Console.WriteLine(e.Message);
         throw;
     }
 }
示例#7
0
 public void TestInconsistentLanguageString()
 {
     ConfigTools.InitConf("Config.xml");
     try
     {
         ConfigTools.SetLanguage("coucou");
     }
     catch (LanguageException e)
     {
         Console.WriteLine(e.Message);
         throw;
     }
 }
示例#8
0
 public void TestNullLanguageString()
 {
     ConfigTools.InitConf("Config.xml");
     try
     {
         ConfigTools.SetLanguage((string)null);
     }
     catch (LanguageException e)
     {
         Console.WriteLine(e.Message);
         throw;
     }
 }
示例#9
0
        public void TestDefaultLanguageMessages()
        {
            ResourceManager rm = new ResourceManager(typeof(LightNovelSniffer_Strings));
            string          defaultTemplate = rm.GetString("CoverDownloadExceptionMessage");

            string url = "coucou";

            ConfigTools.InitConf("Config.xml");
            try
            {
                WebCrawler.DownloadCover(url);
            }
            catch (CoverException e)
            {
                Console.WriteLine(e.Message);

                string localizedTemplate = rm.GetString("CoverDownloadExceptionMessage");
                Assert.AreEqual(e.Message, string.Format(defaultTemplate, url));
                Assert.AreEqual(e.Message, string.Format(localizedTemplate, url));
                throw;
            }
        }
示例#10
0
 public static void ClassInit(TestContext context)
 {
     ConfigTools.InitConf("Config.xml");
     ConfigTools.InitLightNovels("LightNovels.xml");
 }
示例#11
0
 public void Initialize()
 {
     ConfigTools.InitConf("Config.xml");
     Globale.INTERACTIVE_MODE = false;
 }
示例#12
0
        public static void Main(string[] args)
        {
            fileStream = new FileStream("log.txt", FileMode.Create, FileAccess.Write);
            fileWriter = new FileWriter(fileStream);

            try
            {
                ConfigTools.InitConf("Config.xml");
                ConfigTools.InitConf("Config_user.xml");
                ConfigTools.InitLightNovels("LightNovels.xml", true);
                ConfigTools.InitLightNovels("LightNovels_user.xml", true);
                consoleTools = new ConsoleTools(fileWriter, 1);
                ConsoleTools ctForCore = new ConsoleTools(fileWriter, 3);
                lightNovelSniffer = new LNS(ctForCore, ctForCore);
            }
            catch (ApplicationException e)
            {
                consoleTools.Log(e.Message);
                return;
            }

            ShowBannier();
            consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramStart);

            if (!consoleTools.Ask(String.Format(LightNovelSniffer_CLI_Strings.AskOutputFolderConfirmation, Globale.OUTPUT_FOLDER)))
            {
                string folder = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskOutputFolder);
                if (!string.IsNullOrEmpty(folder))
                {
                    Globale.OUTPUT_FOLDER = folder;
                }
            }

            foreach (LnParameters ln in Globale.LN_TO_RETRIEVE)
            {
                if (consoleTools.Ask(string.Format(LightNovelSniffer_CLI_Strings.AskRetrieveLn, ln.name)))
                {
                    GetNovel(ln);
                }
            }

            if (Globale.INTERACTIVE_MODE && consoleTools.AskNegative(LightNovelSniffer_CLI_Strings.LogEndOfLnInConfig))
            {
                LnParameters ln;
                do
                {
                    ln = BuildDynamicLn();
                    GetNovel(ln);
                } while (!string.IsNullOrEmpty(ln.name));
            }

            consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramEnd);

            fileWriter.Close();
            fileStream.Close();

            if (Globale.INTERACTIVE_MODE)
            {
                Console.ReadLine();
            }
        }