public void ShouldConfigureFromString()
        {
            // Arrange
            HmacConfigurationManager configurationManager  = new HmacConfigurationManager();
            HmacConfiguration        expectedConfiguration = new HmacConfiguration
            {
                Name                   = "TestConfiguration",
                UserHeaderName         = "X-Test-User",
                AuthorizationScheme    = "TEST",
                SignatureDataSeparator = "_",
                SignatureEncoding      = "UTF-32",
                HmacAlgorithm          = "HMACSHA256",
                MaxRequestAge          = TimeSpan.FromMinutes(2),
                SignRequestUri         = false,
                ValidateContentMd5     = true,
                Headers                = new List <string> {
                    "X-Test-Header-1", "X-Test-Header-2"
                }
            };

            // Act
            configurationManager.ConfigureFromString(_hmacConfig, HmacConfigurationFormat.Xml);
            IHmacConfiguration configuration = configurationManager.Get(expectedConfiguration.Name);

            // Assert
            AssertConfiguration(expectedConfiguration, configuration);
        }
        public void ShouldContainsConfiguration()
        {
            // Arrange
            HmacConfigurationManager configurationManager = new HmacConfigurationManager();
            const string             existingConfigKey    = "TestConfiguration";
            const string             nonExistingConfigKey = "Wrong_TestConfiguration";

            // Act
            configurationManager.ConfigureFromString(_hmacModifiedConfig, HmacConfigurationFormat.Xml);

            bool existingConfigFound    = configurationManager.Contains(existingConfigKey);
            bool nonExistingConfigFound = configurationManager.Contains(nonExistingConfigKey);

            // Assert
            Assert.IsTrue(existingConfigFound);
            Assert.IsFalse(nonExistingConfigFound);
        }
        public void ShouldGetAllKeys()
        {
            // Arrange
            HmacConfigurationManager configurationManager = new HmacConfigurationManager();

            string[] expectedKeys =
            {
                "TestConfiguration",
                "TestConfiguration2"
            };

            // Act
            configurationManager.ConfigureFromString(_hmacModifiedConfig, HmacConfigurationFormat.Xml);
            ICollection <string> keys = configurationManager.GetAllKeys();

            // Assert
            Assert.IsNotNull(keys);
            Assert.IsTrue(expectedKeys.All(keys.Contains));
        }
        public void ShouldTryGetConfiguration()
        {
            // Arrange
            HmacConfigurationManager configurationManager = new HmacConfigurationManager();
            const string             existingConfigKey    = "TestConfiguration";
            const string             nonExistingConfigKey = "Wrong_TestConfiguration";

            // Act
            configurationManager.ConfigureFromString(_hmacModifiedConfig, HmacConfigurationFormat.Xml);

            IHmacConfiguration existingConfig;
            IHmacConfiguration nonExistingConfig;

            bool existingConfigFound    = configurationManager.TryGet(existingConfigKey, out existingConfig);
            bool nonExistingConfigFound = configurationManager.TryGet(nonExistingConfigKey, out nonExistingConfig);

            // Assert
            Assert.IsNotNull(existingConfig);
            Assert.IsNull(nonExistingConfig);
            Assert.IsTrue(existingConfigFound);
            Assert.IsFalse(nonExistingConfigFound);
        }