コード例 #1
0
		public void CanBuildCustomSymmetricProviderFromGivenConfiguration()
		{
			CustomSymmetricCryptoProviderData customData
				= new CustomSymmetricCryptoProviderData("custom", typeof(MockCustomSymmetricProvider));
			customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
			CryptographySettings settings = new CryptographySettings();
			settings.SymmetricCryptoProviders.Add(customData);

			DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
			configurationSource.Add(CryptographyConfigurationView.SectionName, settings);

			ISymmetricCryptoProvider custom
				= EnterpriseLibraryFactory.BuildUp<ISymmetricCryptoProvider>("custom", configurationSource);

			Assert.IsNotNull(custom);
			Assert.AreSame(typeof(MockCustomSymmetricProvider), custom.GetType());
			Assert.AreEqual("value1", ((MockCustomSymmetricProvider)custom).customValue);
		}
コード例 #2
0
		public void CanBuildCustomSymmetricProviderFromSavedConfiguration()
		{
			CustomSymmetricCryptoProviderData customData
				= new CustomSymmetricCryptoProviderData("custom", typeof(MockCustomSymmetricProvider));
			customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
			CryptographySettings settings = new CryptographySettings();
			settings.SymmetricCryptoProviders.Add(customData);

			IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(1);
			sections[CryptographyConfigurationView.SectionName] = settings;
			IConfigurationSource configurationSource 
				= ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

			ISymmetricCryptoProvider custom
				= EnterpriseLibraryFactory.BuildUp<ISymmetricCryptoProvider>("custom", configurationSource);

			Assert.IsNotNull(custom);
			Assert.AreSame(typeof(MockCustomSymmetricProvider), custom.GetType());
			Assert.AreEqual("value1", ((MockCustomSymmetricProvider)custom).customValue);
		}
 public void Given()
 {
     cryptographySettings = new CryptographySettings();
     customSymmetricCryptoProviderData =
         new CustomSymmetricCryptoProviderData("custom", typeof(MockCustomSymmetricProvider));
     customSymmetricCryptoProviderData.Attributes["foo"] = "bar";
     cryptographySettings.SymmetricCryptoProviders.Add(customSymmetricCryptoProviderData);
 }