GetSchema() 공개 메소드

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
리턴 dynamic
예제 #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");
            });
        }
예제 #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"));
        }
예제 #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(""));
 }
예제 #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"));
 }
예제 #5
0
 public void GetCollectionSchema_NullProjectId_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => client.GetSchema(null));
 }