public void GetCollectionSchema_ValidProject_Success() { var client = new KeenClient(settingsEnv); if (UseMocks) client.EventCollection = new EventCollectionMock(settingsEnv, GetSchema: new Func<string, IProjectSettings, JObject>((c, p) => { if ((p == settingsEnv) && (c == "AddEventTest")) return JObject.Parse("{\"properties\":{\"AProperty\": \"string\"}}"); else throw new KeenResourceNotFoundException(c); })); Assert.DoesNotThrow(() => { dynamic response = client.GetSchema("AddEventTest"); Assert.NotNull(response["properties"]); Assert.NotNull(response["properties"]["AProperty"]); Assert.True((string)response["properties"]["AProperty"] == "string"); }); }
public void GetCollectionSchema_ValidProjectIdInvalidSchema_Throws() { var client = new KeenClient(settingsEnv); if (UseMocks) client.EventCollection = new EventCollectionMock(settingsEnv, GetSchema: new Func<string, IProjectSettings, JObject>((c, p) => { if ((p == settingsEnv) && (c == "DoesntExist")) throw new KeenResourceNotFoundException(); return new JObject(); })); Assert.Throws<KeenResourceNotFoundException>(() => client.GetSchema("DoesntExist")); }
public void GetCollectionSchema_EmptyProjectId_Throws() { var settings = new ProjectSettingsProvider(projectId: "X", masterKey: settingsEnv.MasterKey); var client = new KeenClient(settings); Assert.Throws<KeenException>(() => client.GetSchema("")); }
public void GetCollectionSchema_InvalidProjectId_Throws() { var settings = new ProjectSettingsProvider(projectId: "X", masterKey: settingsEnv.MasterKey); var client = new KeenClient(settings); if (UseMocks) client.EventCollection = new EventCollectionMock(settings, GetSchema: new Func<string, IProjectSettings, JObject>((c, p) => { if ((p == settings) && (c == "X")) throw new KeenResourceNotFoundException(); else throw new Exception("Unexpected value"); })); Assert.Throws<KeenResourceNotFoundException>(() => client.GetSchema("X")); }
public void GetCollectionSchema_NullProjectId_Throws() { var client = new KeenClient(settingsEnv); Assert.Throws<KeenException>(() => client.GetSchema(null)); }