private void RefreshEnvironments()
        {
            _settings = new EnvironmentSettingsCollection(_source);
            var envs = new EnvironmentCollection(_settings);

            _environments = new GenFormEnvironmentCollection(envs);
        }
        private EnvironmentSettingsCollection GetIsolatedEnvironmentSettingsCollection()
        {
            SecureSettingSource = new TestSource();
            _setting            = Isolate.Fake.Instance <ISetting>();
            Isolate.WhenCalled(() => SecureSettingSource.Add(_setting)).CallOriginal();

            var col = new EnvironmentSettingsCollection(SecureSettingSource);

            return(col);
        }
        public void TurnTheSettingNameInMachineEnvironmentNameAndProvider()
        {
            var source      = new TestSource();
            var settingname = "TestMachine.TestEnvironment.Test.MyProvider";

            source.Add(SettingFactory.CreateSecureSetting(new ConnectionStringSettings(settingname, string.Empty)));
            var col = new EnvironmentSettingsCollection(source);

            Assert.AreEqual("MyProvider", col.Single(s => s.Name == "Test").Provider);
        }
        public void NotAcceptTwiceASettingWithTheSameNameForTestMachine1AndEnv1()
        {
            _source = new TestSource
            {
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Other test")
            };

            var col = new EnvironmentSettingsCollection(_source);

            Assert.AreEqual(1, col.Count);
        }
Esempio n. 5
0
        private EnvironmentSettingsCollection GetIsolatedEnvironmentSettingsCollection()
        {
            _source  = new TestSource();
            _setting = Isolate.Fake.Instance <ISetting>();
            Isolate.WhenCalled(() => _source.Add(_setting)).CallOriginal();

            _keyMan = Isolate.Fake.Instance <SecretKeyManager>();
            Isolate.WhenCalled(() => _keyMan.GetKey()).WillReturn("secretkey");

            var col = new EnvironmentSettingsCollection(_source);

            return(col);
        }
        public void ContainOneEnvironmnentAsSpecifiedInTheTestSource()
        {
            _source = new TestSource
            {
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test2.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test3.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test4.Provider", "Test")
            };
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Assert.AreEqual(1, col.Count);
        }
        public void ContainOneEnvironmnentAsSpecifiedInTheTestSource()
        {
            _source = new TestSource
                             {
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test2.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test3.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test4.Provider", "Test")
                             };
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Assert.AreEqual(1, col.Count);
        }
        public void UseEnvironmentSettingsToAdAnEnvironment()
        {
            var env = new Environment("Test", "Test");

            env.AddSetting("Test", "Test");

            _source   = new TestSource();
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Isolate.WhenCalled(() => _settings.Add(null)).IgnoreCall();
            col.Add(env);
            Isolate.Verify.WasCalledWithAnyArguments(() => _settings.Add(null));
        }
        public void ContainFourEnvironmnentsForTestMachine1AsSpecifiedInTheUnsortedTestSource()
        {
            _source = new TestSource
            {
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env2.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine2.Env1.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine2.Env2.Test2.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test2.Provider", "Test")
            };

            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Assert.AreEqual(4, col.Count());
        }
        public void ContainFourEnvironmnentsForTestMachine1AsSpecifiedInTheUnsortedTestSource()
        {
            _source = new TestSource
                             {
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env2.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine2.Env1.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine2.Env2.Test2.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test2.Provider", "Test")
                             };

            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Assert.AreEqual(4, col.Count());
        }
        public void UseAnEnvironmentSettingsToEnumerateThroughEnvironments()
        {
            _source   = new TestSource();
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            try
            {
                Isolate.WhenCalled(() => _settings.GetEnumerator()).CallOriginal();
                Assert.IsFalse(col.Any(s => s.Name == "TestEnvironment"));
                Isolate.Verify.WasCalledWithAnyArguments(() => _settings.GetEnumerator());
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
Esempio n. 12
0
        private void Init()
        {
            _source = new TestSource
            {
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>(GetDatabaseSettingName(),
                                                                              DatabaseConnection),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>(GetLogPathSettingName(),
                                                                              LogPath),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>(GetExportPathSettingName(),
                                                                              ExportPath)
            };

            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            _environments = new GenFormEnvironmentCollection(col);
        }
        public void ContainThreeEnvironmnentSettingsForTestMachine1AndEnv2AsSpecifiedInTheUnsortedTestSource()
        {
            _source = new TestSource
            {
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env2.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine2.Env1.Test1.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine2.Env2.Test2.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env2.Test2.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env2.Test3.Provider", "Test"),
                SettingFactory.CreateSecureSetting <ConnectionStringSettings>("TestMachine1.Env1.Test2.Provider", "Test")
            };

            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Assert.AreEqual(3, col.Single(e => e.MachineName == "TestMachine1" && e.Name == "Env2").Settings.Count());
        }
        public void ContainThreeEnvironmnentSettingsForTestMachine1AndEnv2AsSpecifiedInTheUnsortedTestSource()
        {
            _source = new TestSource
                             {
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env2.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine2.Env1.Test1.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine2.Env2.Test2.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env2.Test2.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env2.Test3.Provider", "Test"),
                                 SettingFactory.CreateSecureSetting<ConnectionStringSettings>("TestMachine1.Env1.Test2.Provider", "Test")
                             };

            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Assert.AreEqual(3, col.Single(e => e.MachineName == "TestMachine1" && e.Name == "Env2").Settings.Count());
        }
Esempio n. 15
0
        private void GetEnvironment(string database, string logpath, string exportpath, string connectionstring, string provider)
        {
            _settings = GetIsolatedEnvironmentSettingsCollection();
            if (!string.IsNullOrWhiteSpace(database))
            {
                _settings.AddSetting(MachineName, EnvironmentName, database, provider, connectionstring);
            }
            if (!string.IsNullOrWhiteSpace(logpath))
            {
                _settings.AddSetting(MachineName, EnvironmentName, logpath, provider);
            }
            if (!string.IsNullOrWhiteSpace(exportpath))
            {
                _settings.AddSetting(MachineName, EnvironmentName, exportpath, provider);
            }

            _environment        = new Environment(MachineName, EnvironmentName, _settings);
            _genFormEnvironment = new GenFormEnvironment(_environment);
        }
        public static GenFormEnvironment CreateTestGenFormEnvironment()
        {
            var source = new TestSource();

            var keyMan = Isolate.Fake.Instance <SecretKeyManager>();

            Isolate.WhenCalled(() => keyMan.GetKey()).WillReturn("secret");
            Isolate.WhenCalled(() => keyMan.SetKey("secret")).IgnoreCall();


            var envSets = new EnvironmentSettingsCollection(source);

            envSets.AddSetting("MyMachine", "Test", "Database", "Provider", "Some connection string");
            envSets.AddSetting("MyMachine", "Test", "LogPath", "File", string.Empty);
            envSets.AddSetting("MyMachine", "Test", "ExportPath", "File", string.Empty);

            var env = new Environment("MyMachine", "Test", envSets);

            return(new GenFormEnvironment(env));
        }
        public EnvironmentSettingsCollection GetIsolatedEnvironmentSettingsCollectionWithSettings()
        {
            SecureSettingSource = new TestSource();
            SecureSettingSource.Add(SettingFactory.CreateSecureSetting <ConnectionStringSettings>("MyMachine.TestEnvironment.Database.SqlProvider", "Connection string to database"));
            //SettingSource.Add(new Setting("MyMachine.TestEnvironment.Database.SqlProvider", "Connection string to database", "Conn", false));
            //SettingSource.Add(new Setting("MyMachine.TestEnvironment.LogPath.FileSystem", "Path to logp", "Conn", false));
            //SettingSource.Add(new Setting("MyMachine.TestEnvironment.ExportPath.FileSystem", "Path to export", "Conn", false));

            //SettingSource.Add(new Setting("OtherMachine.OtherEnvironment.Database.SqlProvider", "Connection string to database", "Conn", false));
            //SettingSource.Add(new Setting("OtherMachine.OtherEnvironment.LogPath.FileSystem", "Path to logp", "Conn", false));
            //SettingSource.Add(new Setting("OtherMachine.OtherEnvironment.ExportPath.FileSystem", "Path to export", "Conn", false));

            KeyManager = Isolate.Fake.Instance <SecretKeyManager>();
            Isolate.WhenCalled(() => KeyManager.GetKey()).WillReturn("secretkey");

            CryptoGraphy = new CryptographyAdapter(new SymCryptography());

            var col = new EnvironmentSettingsCollection(SecureSettingSource);

            return(col);
        }
Esempio n. 18
0
 private void SetupFakeEnvironmentSettings()
 {
     _fakeEnvironmentSettings = Isolate.Fake.Instance <EnvironmentSettingsCollection>();
     Isolate.WhenCalled(() => _fakeEnvironmentSettings.Any()).WillReturn(false);
 }
        public void UseAnEnvironmentSettingsToEnumerateThroughEnvironments()
        {
            _source = new TestSource();
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            try
            {
                Isolate.WhenCalled(() => _settings.GetEnumerator()).CallOriginal();
                Assert.IsFalse(col.Any(s => s.Name == "TestEnvironment"));
                Isolate.Verify.WasCalledWithAnyArguments(() => _settings.GetEnumerator());
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
        public void UseEnvironmentSettingsToAdAnEnvironment()
        {
            var env = new Environment("Test", "Test");
            env.AddSetting("Test", "Test");

            _source = new TestSource();
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Isolate.WhenCalled(() => _settings.Add(null)).IgnoreCall();
            col.Add(env);
            Isolate.Verify.WasCalledWithAnyArguments(() => _settings.Add(null));
        }
 private void RefreshEnvironments()
 {
     _settings = new EnvironmentSettingsCollection(_source);
     var envs = new EnvironmentCollection(_settings);
     _environments = new GenFormEnvironmentCollection(envs);
 }
Esempio n. 22
0
        private void GetEnvironment(string database, string logpath, string exportpath, string connectionstring, string provider)
        {
            _settings = GetIsolatedEnvironmentSettingsCollection();
            if (!string.IsNullOrWhiteSpace(database)) _settings.AddSetting(MachineName, EnvironmentName, database, provider, connectionstring);
            if (!string.IsNullOrWhiteSpace(logpath)) _settings.AddSetting(MachineName, EnvironmentName, logpath, provider);
            if (!string.IsNullOrWhiteSpace(exportpath)) _settings.AddSetting(MachineName, EnvironmentName, exportpath, provider);

            _environment = new Environment(MachineName, EnvironmentName, _settings);
            _genFormEnvironment = new GenFormEnvironment(_environment);
        }
Esempio n. 23
0
        private EnvironmentSettingsCollection GetIsolatedEnvironmentSettingsCollection()
        {
            _source = new TestSource();
            _setting = Isolate.Fake.Instance<ISetting>();
            Isolate.WhenCalled(() => _source.Add(_setting)).CallOriginal();

            _keyMan = Isolate.Fake.Instance<SecretKeyManager>();
            Isolate.WhenCalled(() => _keyMan.GetKey()).WillReturn("secretkey");

            var col = new EnvironmentSettingsCollection(_source);

            return col;
        }
Esempio n. 24
0
 private void SetupFakeEnvironmentSettings()
 {
     _fakeEnvironmentSettings = Isolate.Fake.Instance<EnvironmentSettingsCollection>();
     Isolate.WhenCalled(() => _fakeEnvironmentSettings.Any()).WillReturn(false);
 }