Пример #1
0
        public void ShouldSaveProxySettingsToFile()
        {
            using (var savedData = new MemoryStream()) {
                var config = new FirefoxConfigReader();
                using (var reader = new StringReader(Properties.Resources.FFPrefsProxyDisabled)) {
                    config.LoadConfig(reader);
                }
                config.SetProxySettings(testProxy);

                using (var writer = new StreamWriter(savedData)) {
                    writer.AutoFlush = true;
                    config.SaveConfig(writer);

                    savedData.Flush();
                    savedData.Seek(0, SeekOrigin.Begin);
                    var rows = new HashSet <string>();
                    using (var reader = new StreamReader(savedData)) {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            rows.Add(line);
                        }
                    }
                    using (var reader = new StringReader(Properties.Resources.FFPrefs)) {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            Assert.AreEqual(true, rows.Contains(line));
                        }
                    }
                }
            }
        }
Пример #2
0
 public void ShouldReadProxySettingsDisabled()
 {
     using (var reader = new StringReader(Properties.Resources.FFPrefsProxyDisabled)) {
         var config = new FirefoxConfigReader();
         config.LoadConfig(reader);
         var settings = config.ProxySettings();
         Assert.AreEqual(false, settings.Enabled);
     }
 }
Пример #3
0
 public void ShouldSetHomePage()
 {
     using (var reader = new StringReader(Properties.Resources.FFPrefs)) {
         var config = new FirefoxConfigReader();
         config.LoadConfig(reader);
         config.SetHomePage(HomePage);
         Assert.AreEqual(HomePage, config.Homepage());
     }
 }
Пример #4
0
        public void ShouldReadProxySettingsEnabled()
        {
            using (var reader = new StringReader(Properties.Resources.FFPrefs)) {
                var config = new FirefoxConfigReader();
                config.LoadConfig(reader);
                var settings = config.ProxySettings();
                Assert.AreEqual("1.1.1.1", settings.HTTP);
                Assert.AreEqual("2.2.2.2", settings.SSL);
                Assert.AreEqual("3.3.3.3", settings.FTP);
                Assert.AreEqual("4.4.4.4", settings.Socks);

                Assert.AreEqual(80, settings.HTTPPort);
                Assert.AreEqual(81, settings.SSLPort);
                Assert.AreEqual(82, settings.FTPPort);
                Assert.AreEqual(83, settings.SocksPort);

                Assert.AreEqual(false, settings.UseAdrForAll);
                Assert.AreEqual(true, settings.Enabled);
            }
        }
Пример #5
0
        public void ShouldSaveHomePage()
        {
            using (var savedData = new MemoryStream()) {
                var config = new FirefoxConfigReader();
                using (var reader = new StringReader(Properties.Resources.FFPrefs)) {
                    config.LoadConfig(reader);
                    config.SetHomePage(HomePage);
                }

                using (var writer = new StreamWriter(savedData)) {
                    writer.AutoFlush = true;
                    config.SaveConfig(writer);
                    savedData.Flush();
                    savedData.Seek(0, SeekOrigin.Begin);

                    using (var reader = new StreamReader(savedData)) {
                        var config2 = new FirefoxConfigReader();
                        config2.LoadConfig(reader);
                        Assert.AreEqual(HomePage, config2.Homepage());
                    }
                }
            }
        }