public void CreateAccessKey_Success() { var settings = new ProjectSettingsProvider(projectId: "X", masterKey: SettingsEnv.MasterKey); // Replace X with respective value var client = new KeenClient(settings); if (UseMocks) { client.AccessKeys = new AccessKeysMock(settings, createAccessKey: new Func <AccessKey, IProjectSettings, JObject>((e, p) => { Assert.True(p == settings, "Incorrect Settings"); Assert.NotNull(e.Name, "Expected a name for the newly created Key"); Assert.NotNull(e.Permitted, "Expected a list of high level actions this key can perform"); Assert.NotNull(e.Options, "Expected an object containing more details about the key’s permitted and restricted functionality"); if ((p == settings) && (e.Name == "TestAccessKey") && (e.IsActive) && e.Permitted.First() == "queries" && e.Options.CachedQueries.Allowed.First() == "my_cached_query") { return(new JObject()); } else { throw new Exception("Unexpected value"); } })); } HashSet <string> permissions = new HashSet <string>() { "queries" }; List <QueryFilter> qFilters = new List <QueryFilter>() { new QueryFilter("customer.id", QueryFilter.FilterOperator.Equals(), "asdf12345z") }; CachedQueries cachedQueries = new CachedQueries(); cachedQueries.Allowed = new HashSet <string>() { "my_cached_query" }; Options options = new Options() { Queries = new Core.AccessKey.Queries { Filters = qFilters }, CachedQueries = cachedQueries }; Assert.DoesNotThrow(() => client.CreateAccessKey(new AccessKey { Name = "TestAccessKey", IsActive = true, Options = options, Permitted = permissions })); }