public void AuthenticationPasses()
    {
      var context = new OAuthContext { XAuthMode = "client_auth", XAuthUsername = "******", XAuthPassword = "******" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      Assert.DoesNotThrow(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
    }
    public void EmptyPasswordThrows()
    {
      var context = new OAuthContext { XAuthMode = "client_auth", XAuthUsername = "******" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
      Assert.Equal("The x_auth_password parameter must be present", ex.Message);
    }
    public void AuthenticationFailureThrows()
    {
      var context = new OAuthContext { XAuthMode = "client_auth", XAuthUsername = "******", XAuthPassword = "******" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
      Assert.Equal("Authentication failed with the specified username and password", ex.Message);
    }
    public void InvalidModeThrows()
    {
      var context = new OAuthContext { XAuthMode = "test_mode" };

      var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
      var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
      Assert.Equal("The x_auth_mode parameter is invalid", ex.Message);
    }