コード例 #1
0
        public void LoadStreamUsingPassword()
        {
            var storePath = Path.GetTempFileName();

            CreateTestStore(storePath, Password, KeyType.Password);

            var provider = new SecureStoreConfigurationProvider(new SecureStoreConfigurationSource
            {
                KeyType  = KeyType.Password,
                Key      = Password,
                Optional = true
            });

            using (var stream = new FileStream(storePath, FileMode.Open, FileAccess.Read))
            {
                provider.Load(stream);
            }

            File.Delete(storePath);
        }
コード例 #2
0
        public void LoadStreamUsingPassword_ThrowsIfKeyTypeNotInRange()
        {
            var storePath = Path.GetTempFileName();

            CreateTestStore(storePath, Password, KeyType.Password);

            var source = new SecureStoreConfigurationSource
            {
                KeyType  = (KeyType)3,
                Key      = Password,
                Optional = true
            };
            var provider = new SecureStoreConfigurationProvider(source);

            using (var stream = new FileStream(storePath, FileMode.Open, FileAccess.Read))
            {
                var ex = Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                                     provider.Load(stream));
                Assert.Equal(nameof(source.KeyType), ex.ParamName);
            }

            File.Delete(storePath);
        }