Exemple #1
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);
        }
Exemple #2
0
        protected void SetupSecureSettingSource()
        {
            Configuration = Isolate.Fake.Instance <Configuration>();
            Factory       = new TestConfigurationFactory(Configuration);

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

            CryptoGraphy = Isolate.Fake.Instance <CryptoGraphy>();
            Isolate.WhenCalled(() => CryptoGraphy.SetKey(Key)).IgnoreCall();
            Name      = "secret";
            Encrypted = "[Secure]=";
            Isolate.WhenCalled((() => CryptoGraphy.Encrypt(Name))).WillReturn(Encrypted);
            Isolate.WhenCalled((() => CryptoGraphy.Decrypt(Encrypted))).WillReturn(Name);

            SecureSettingSource = new ConfigurationSettingSource(Factory);
        }