Ejemplo n.º 1
0
        public void ThatSettingsHasCountZeroWhenEnvironmentIsNew()
        {
            SetupFakeEnvironmentSettings();
            var env = new Environment("Test", "Test", _fakeEnvironmentSettings);

            Assert.IsTrue(!env.Settings.Any());
        }
Ejemplo n.º 2
0
        public void ThatSettingsHasCountZeroWhenEnvironmentIsNew()
        {
            SetupFakeEnvironmentSettings();
            var env = new Environment("Test", "Test", _fakeEnvironmentSettings);

            Assert.IsTrue(!env.Settings.Any());
        }
Ejemplo n.º 3
0
        public void MachineNameIsSetToMacineNameSuppliedInConstructor()
        {
            var machine = "MyMachine";
            var env     = new Environment(machine, "test");

            Assert.AreEqual(machine, env.MachineName);
        }
Ejemplo n.º 4
0
        public void MachineNameIsSetToMacineNameSuppliedInConstructor()
        {
            var machine = "MyMachine";
            var env = new Environment(machine, "test");

            Assert.AreEqual(machine, env.MachineName);
        }
Ejemplo n.º 5
0
 public void ThatWhenAnEnvironmentIsCreatedWithoutANameAnExceptionIsThrown()
 {
     try
     {
         Environment.Create("Test", string.Empty);
         Assert.Fail("An exception should be thrown");
     }
     catch (Exception e)
     {
         Assert.IsNotInstanceOfType(e, typeof(AssertFailedException));
     }
 }
        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));
        }
Ejemplo n.º 7
0
        public void SettingsUsesEnvironmentSettingsToGetTheSettings()
        {
            SetupFakeEnvironmentSettings();
            var env = new Environment("Test", "Test", _fakeEnvironmentSettings);

            try
            {
                Assert.IsTrue(!env.Settings.Any());
                Isolate.Verify.WasCalledWithAnyArguments(() => _fakeEnvironmentSettings.Any());
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
Ejemplo n.º 8
0
        public void SettingsUsesEnvironmentSettingsToGetTheSettings()
        {
            SetupFakeEnvironmentSettings();
            var env = new Environment("Test", "Test", _fakeEnvironmentSettings);

            try
            {
                Assert.IsTrue(!env.Settings.Any());
                Isolate.Verify.WasCalledWithAnyArguments(() => _fakeEnvironmentSettings.Any());
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 11
0
        public void ThatMachineIsSetToLocalMachineNameWhenNotExplicitlySetInConstructor()
        {
            var env = Environment.Create(System.Environment.MachineName, "Test");

            Assert.AreEqual(System.Environment.MachineName, env.MachineName);
        }
Ejemplo n.º 12
0
        public void ThatNameHasAValueWhenEnvironmentIsCreated()
        {
            var env = Environment.Create("Test", "Test");

            Assert.AreEqual("Test", env.Name);
        }
        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));
        }
Ejemplo n.º 14
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);
        }