public void GetKeyFromAppsetting_AppsettingMissing_ThrowsException() { var validator = new Mock<ISessionAuthenticationKeyValidator>(MockBehavior.Strict); //Throws MockException var helper = new AppsettingKeyHelper(new NameValueCollection(), validator.Object); Assert.Throws<ApplicationException>(() => helper.GetKeyFromAppsetting("authKey")); }
public void GetKeyFromAppsetting_InvalidKeyConfigured_ThrowsException() { _mockValidator = new Mock<ISessionAuthenticationKeyValidator>(); string failure; _mockValidator.Setup(v => v.IsValidKey(AppsettingKey, out failure)).Returns(false); var appsettings = new NameValueCollection { { "authKey", AppsettingKey } }; var helper = new AppsettingKeyHelper(appsettings, _mockValidator.Object); Assert.Throws<ApplicationException>(() => helper.GetKeyFromAppsetting("authKey")); }
public void GetKeyFromAppsetting_ValidKeyConfigured_ReturnsKey() { _mockValidator = new Mock<ISessionAuthenticationKeyValidator>(); string failure; _mockValidator.Setup(v => v.IsValidKey(AppsettingKey, out failure)).Returns(true); var appsettings = new NameValueCollection { { "authKey", AppsettingKey } }; var helper = new AppsettingKeyHelper(appsettings, _mockValidator.Object); var key = helper.GetKeyFromAppsetting("authKey"); Assert.AreEqual(_expectedAppsettingKey, key); }