public void VerifyConfigurationBinding() { HMACHashDelegateConfig expectedConfig = new HMACHashDelegateConfig() { PseudoRandomFunction = Microsoft.AspNetCore.Cryptography.KeyDerivation.KeyDerivationPrf.HMACSHA1, Iterations = 100, SaltLength = 8, }; var myConfiguration = new Dictionary <string, string> { { "HMACHash:PseudoRandomFunction", expectedConfig.PseudoRandomFunction.ToString() }, { "HMACHash:Iterations", expectedConfig.Iterations.ToString() }, { "HMACHash:SaltLength", expectedConfig.SaltLength.ToString() }, }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); HMACHashDelegate hashDelegate = new HMACHashDelegate( new Mock <ILogger <HMACHashDelegate> >().Object, configuration); Assert.True(expectedConfig.IsDeepEqual(hashDelegate.HashConfig)); }
public void VerifyDefaultConfigurationBinding() { HMACHashDelegateConfig expectedConfig = new HMACHashDelegateConfig() { PseudoRandomFunction = HMACHashDelegateConfig.DefaultPseudoRandomFunction, Iterations = HMACHashDelegateConfig.DefaultIterations, SaltLength = HMACHashDelegateConfig.DefaultSaltLength, }; var myConfiguration = new Dictionary <string, string> { //test empty configuration }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); HMACHashDelegate hashDelegate = new HMACHashDelegate( new Mock <ILogger <HMACHashDelegate> >().Object, configuration); Assert.True(expectedConfig.IsDeepEqual(hashDelegate.HashConfig)); }