GetSchema() public method

Retrieve the schema for the specified collection. This requires a value for the project settings Master API key.
public GetSchema ( string collection ) : dynamic
collection string
return dynamic
Ejemplo n.º 1
0
        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");
            });
        }
Ejemplo n.º 2
0
        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"));
        }
Ejemplo n.º 3
0
 public void GetCollectionSchema_EmptyProjectId_Throws()
 {
     var settings = new ProjectSettingsProvider(projectId: "X", masterKey: settingsEnv.MasterKey);
     var client = new KeenClient(settings);
     Assert.Throws<KeenException>(() => client.GetSchema(""));
 }
Ejemplo n.º 4
0
 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"));
 }
Ejemplo n.º 5
0
 public void GetCollectionSchema_NullProjectId_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => client.GetSchema(null));
 }