public void CreateDefaultProvider() { HashProviderFactory factory = new HashProviderFactory(CreateSource(providerName)); IHashProvider provider = factory.CreateDefault(); Assert.AreEqual(typeof(KeyedHashAlgorithmProvider), provider.GetType()); }
public void CreateHashByNameTest() { HashProviderFactory factory = new HashProviderFactory(CreateSource(hashAlgorithm)); IHashProvider provider = factory.Create(hashAlgorithm); Assert.AreEqual(typeof(HashAlgorithmProvider), provider.GetType()); }
public void CanBuildCustomHashProviderFromGivenConfiguration() { CustomHashProviderData customData = new CustomHashProviderData("custom", typeof(MockCustomHashProvider)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CryptographySettings settings = new CryptographySettings(); settings.HashProviders.Add(customData); DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); configurationSource.Add(CryptographyConfigurationView.SectionName, settings); IHashProvider custom = EnterpriseLibraryFactory.BuildUp <IHashProvider>("custom", configurationSource); Assert.IsNotNull(custom); Assert.AreSame(typeof(MockCustomHashProvider), custom.GetType()); Assert.AreEqual("value1", ((MockCustomHashProvider)custom).customValue); }
public void CanBuildCustomHashProviderFromSavedConfiguration() { CustomHashProviderData customData = new CustomHashProviderData("custom", typeof(MockCustomHashProvider)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CryptographySettings settings = new CryptographySettings(); settings.HashProviders.Add(customData); IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(1); sections[CryptographyConfigurationView.SectionName] = settings; IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); IHashProvider custom = EnterpriseLibraryFactory.BuildUp <IHashProvider>("custom", configurationSource); Assert.IsNotNull(custom); Assert.AreSame(typeof(MockCustomHashProvider), custom.GetType()); Assert.AreEqual("value1", ((MockCustomHashProvider)custom).customValue); }