예제 #1
0
        public static void ClassInitialize()
        {
            var orchestrate = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "Inital Test Item"};

            orchestrate.Put(CollectionName, "1", item);
        }
예제 #2
0
        public void PutGraph_Properties_Object()
        {
            var data = new TestData { Id = 2, Value = "This is collection 2 data" };
            _orchestrate.Put("GraphTestCollection2", "2", data);

            var result = _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2", data);

            Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty);
        }
예제 #3
0
        public void GetEventAsync()
        {
            var item = new TestData { Id = 3, Value = "A successful object PUT" };
            var eventPosted = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item);
            var eventList = _orchestrate.ListEvents(CollectionName, "1", "comment", 100);
            var firstEvent = eventList.Results.First();

            var result = _orchestrate.GetEventAsync(CollectionName, "1", "comment", Orchestrate.ConvertFromUnixTimeStamp(firstEvent.Path.TimeStamp), firstEvent.Path.Ordinal).Result;

            Assert.IsTrue(result.Ordinal > 0);
        }
예제 #4
0
        public void GetEventBadTimeStamp()
        {
            var item = new TestData { Id = 3, Value = "A successful object PUT" };
            var eventPosted = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item);
            var eventList = _orchestrate.ListEvents(CollectionName, "1", "comment", 100);
            var firstEvent = eventList.Results.First();

            try
            {
                var result = _orchestrate.GetEvent(CollectionName, "1", "comment", DateTime.UtcNow.AddYears(-1000), firstEvent.Path.Ordinal);
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as HttpRequestException;
                Assert.IsTrue(inner?.Message.Contains("404") == true);
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
        public void CreateCollectionWithItemAsObjectAsync()
        {
            // Set up
            const string collectionName = "TestCollection01";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "CreateCollectionWithItemAsObject"};

            try
            {
                var result = orchestration.PutAsync(collectionName, Guid.NewGuid().ToString(), item).Result;

                Assert.IsTrue(result.Path.Ref.Length > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                orchestration.DeleteCollection(collectionName);
            }
        }
        public void CreateCollectionWithItemAsJsonString()
        {
            // Set up
            const string collectionName = "TestCollection02";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "CreateCollectionWithItemAsJsonString"};
            var json = JsonConvert.SerializeObject(item);

            try
            {
                var result = orchestration.Put(collectionName, Guid.NewGuid().ToString(), json);

                Assert.IsTrue(result.Path.Ref.Length > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                orchestration.DeleteCollection(collectionName);
            }
        }
        public void DeleteCollectionNoNameAsync()
        {
            // Set up
            const string collectionName = "TestCollection04";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "DeleteCollection"};
            var json = JsonConvert.SerializeObject(item);

            try
            {
                var result = orchestration.PutAsync(collectionName, Guid.NewGuid().ToString(), json).Result;
                var deleteResult = orchestration.DeleteCollectionAsync(string.Empty).Result;
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as ArgumentNullException;
                Assert.IsTrue(inner?.ParamName == "collectionName");
                orchestration.DeleteCollection(collectionName);
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
        public void DeleteCollectionNoName()
        {
            // Set up
            const string collectionName = "TestCollection04";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "DeleteCollection"};
            var json = JsonConvert.SerializeObject(item);

            try
            {
                orchestration.Put(collectionName, Guid.NewGuid().ToString(), json);
                orchestration.DeleteCollection(string.Empty);
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "collectionName");
                orchestration.DeleteCollection(collectionName);
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #9
0
        public void PutIfNoneMatchWithNoKeyAsync()
        {
            var item = new TestData { Id = 77, Value = "Test Value 77" };

            try
            {
                var result = _orchestrate.PutIfNoneMatchAsync(CollectionName, string.Empty, item).Result;
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as ArgumentNullException;
                Assert.IsTrue(inner?.ParamName == "key");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #10
0
        public void DeleteGraphPurgeAsync()
        {
            var data = new TestData {Id = 2, Value = "This is collection 2 data"};
            _orchestrate.Put("GraphTestCollection2", "2", data);
            _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2");
            var result = _orchestrate.DeleteGraphAsync(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2").Result;

            Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty);
        }
예제 #11
0
        public void GetSingleGraphWithNoKindsAsync()
        {
            var data = new TestData {Id = 2, Value = "This is collection 2 data"};
            _orchestrate.Put("GraphTestCollection2", "2", data);
            _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2");

            try
            {
                var result = _orchestrate.GetGraphAsync(CollectionName, "1", null).Result;
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as ArgumentNullException;
                Assert.IsTrue(inner?.ParamName == "kinds");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #12
0
        public void PostEventNoTimeStampAsync()
        {
            var item = new TestData { Id = 3, Value = "A successful object PUT" };
            var result = _orchestrate.PostEventAsync(CollectionName, "1", "comment", null, item).Result;

            Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty);
        }
예제 #13
0
        public void PutGraphAsync_Properties_String()
        {
            var data = new TestData { Id = 2, Value = "This is collection 2 data" };
            _orchestrate.Put("GraphTestCollection2", "2", data);

            var json = JsonConvert.SerializeObject(data);

            var result =
                _orchestrate.PutGraphAsync(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2", json).Result;

            Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty);
        }
예제 #14
0
        public void ListEvents_DateTime()
        {
            var item1 = new TestData { Id = 3, Value = "A successful object Post 1" };
            var eventPosted1 = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item1);

            var item2 = new TestData { Id = 4, Value = "A successful object Post 2" };
            var eventPosted2 = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item2);

            var eventList = _orchestrate.ListEvents(CollectionName, "1", "comment", 100, startEvent: DateTime.UtcNow.AddDays(-1), endEvent: DateTime.UtcNow.AddDays(1));

            Assert.IsTrue(eventList.Count > 0);
        }
예제 #15
0
        public void ListEventsAsync()
        {
            var item1 = new TestData { Id = 3, Value = "A successful object Post 1" };
            var eventPosted1 = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item1);

            var item2 = new TestData { Id = 4, Value = "A successful object Post 2" };
            var eventPosted2 = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item2);

            var eventList = _orchestrate.ListEventsAsync(CollectionName, "1", "comment", 100).Result;

            Assert.IsTrue(eventList.Count > 0);
        }
예제 #16
0
        public void PutEventAsync_UnixTimeStamp_String_IfMatch()
        {
            var item = new TestData { Id = 3, Value = "A successful object PUT" };
            var eventPosted = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item);
            var eventList = _orchestrate.ListEvents(CollectionName, "1", "comment", 100);
            var firstEvent = eventList.Results.First();

            item.Value = "This was updated";
            var itemString = JsonConvert.SerializeObject(item);

            var result = _orchestrate.PutEventIfMatchAsync(CollectionName, "1", "comment", long.Parse(firstEvent.Path.TimeStamp), firstEvent.Path.Ordinal, itemString, firstEvent.Path.Ref).Result;

            Assert.IsTrue(!string.IsNullOrEmpty(result.Path.Ref));

            var getResult = _orchestrate.GetEvent(CollectionName, "1", "comment", Orchestrate.ConvertFromUnixTimeStamp(firstEvent.Path.TimeStamp), firstEvent.Path.Ordinal);

            Assert.IsTrue(getResult.Value.ToString().Contains("updated"));

        }
예제 #17
0
        public void PostEventWithNoTypeAsync()
        {
            try
            {
                var item = new TestData { Id = 3, Value = "A successful object PUT" };
                var result = _orchestrate.PostEventAsync(CollectionName, "1", string.Empty, null, item).Result;
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as ArgumentNullException;
                Assert.IsTrue(inner?.ParamName == "type");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #18
0
        public void PostEventWithNoType()
        {
            try
            {
                var item = new TestData { Id = 3, Value = "A successful object PUT" };
                _orchestrate.PostEvent(CollectionName, "1", string.Empty, null, item);
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "type");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #19
0
        public void PutGraphIfMatchAsync()
        {
            var data = new TestData { Id = 2, Value = "This is collection 2 data" };
            _orchestrate.Put("GraphTestCollection2", "2", data);
            var kinds = new[] { "toplevelgraph" };

            var graph = _orchestrate.GetGraph(CollectionName, "1", kinds);
            var ref1 = graph.Results.First().Path.Ref;

            var result =
                _orchestrate.PutGraphIfMatchAsync(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2", ref1).Result;

            Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty);
        }
예제 #20
0
        public void GetMultipleLevleGraphAsync()
        {
            var data = new TestData {Id = 2, Value = "This is collection 2 data"};
            _orchestrate.Put("GraphTestCollection2", "2", data);
            _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2");

            data = new TestData {Id = 3, Value = "This is collection 3 data"};
            _orchestrate.Put("GraphTestCollection3", "3", data);
            _orchestrate.PutGraph("GraphTestCollection2", "2", "sublevelgraph", "GraphTestCollection3", "3");

            var kinds = new[] {"toplevelgraph", "sublevelgraph"};

            var result = _orchestrate.GetGraphAsync(CollectionName, "1", kinds).Result;

            Assert.IsTrue(result.Count == 1);
        }
예제 #21
0
        public void ListEventsAsync_TimeStamp()
        {
            var item1 = new TestData { Id = 3, Value = "A successful object Post 1" };
            var eventPosted1 = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item1);

            var item2 = new TestData { Id = 4, Value = "A successful object Post 2" };
            var eventPosted2 = _orchestrate.PostEvent(CollectionName, "1", "comment", DateTime.UtcNow, item2);

            var eventList = _orchestrate.ListEventsAsync(CollectionName, "1", "comment", 100, afterEvent: Orchestrate.ConvertToUnixTimestamp(DateTime.UtcNow.AddDays(-1)), beforeEvent: Orchestrate.ConvertToUnixTimestamp(DateTime.UtcNow.AddDays(1))).Result;

            Assert.IsTrue(eventList.Count > 0);
        }
예제 #22
0
        public void PostEventNowTimeStampAsyncAsString()
        {
            var item = new TestData { Id = 3, Value = "A successful object PUT" };
            var str = JsonConvert.SerializeObject(item);
            var result = _orchestrate.PostEventAsync(CollectionName, "1", "comment", DateTime.UtcNow, str).Result;

            Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty);
        }
예제 #23
0
        public void GetSingleGraph()
        {
            var data = new TestData {Id = 2, Value = "This is collection 2 data"};
            _orchestrate.Put("GraphTestCollection2", "2", data);
            _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2");
            var kinds = new[] {"toplevelgraph"};

            var result = _orchestrate.GetGraph(CollectionName, "1", kinds);

            Assert.IsTrue(result.Count == 1);
        }
예제 #24
0
        public void CreateCollectionNoCollectionName()
        {
            // Set up
            const string collectionName = "";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "CreateCollectionNoCollectionName"};

            try
            {
                orchestration.Put(collectionName, Guid.NewGuid().ToString(), item);
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "collectionName");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #25
0
        public void GetSingleGraphWithNoKinds()
        {
            var data = new TestData {Id = 2, Value = "This is collection 2 data"};
            _orchestrate.Put("GraphTestCollection2", "2", data);
            _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2");

            try
            {
                _orchestrate.GetGraph(CollectionName, "1", null);
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "kinds");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #26
0
        public void CreateCollectionNoCollectionNameAsync()
        {
            // Set up
            const string collectionName = "";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "CreateCollectionNoCollectionName"};

            try
            {
                var result = orchestration.PutAsync(collectionName, Guid.NewGuid().ToString(), item).Result;
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as ArgumentNullException;
                Assert.IsTrue(inner?.ParamName == "collectionName");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }
예제 #27
0
        public void DeleteGraphAsync()
        {
            var data = new TestData {Id = 2, Value = "This is collection 2 data"};
            _orchestrate.Put("GraphTestCollection2", "2", data);
            _orchestrate.PutGraph(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2");
            var result = _orchestrate.DeleteGraphAsync(CollectionName, "1", "toplevelgraph", "GraphTestCollection2", "2").Result;
            var kinds = new[] {"toplevelgraph"};

            try
            {
                _orchestrate.GetGraph(CollectionName, "1", kinds);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("404"));
            }
        }
예제 #28
0
        public void CreateCollectionNoKey()
        {
            // Set up
            const string collectionName = "TestCollection04";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "CreateCollectionNoCollectionName"};

            try
            {
                orchestration.Put(collectionName, string.Empty, item);
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "key");
                return;
            }

            orchestration.DeleteCollection(collectionName);
            Assert.Fail("No Exception Thrown");
        }
예제 #29
0
        public void CreateCollectionNoKeyAsync()
        {
            // Set up
            const string collectionName = "TestCollection04";
            var orchestration = new Orchestrate(TestHelper.ApiKey);
            var item = new TestData {Id = 1, Value = "CreateCollectionNoCollectionName"};

            try
            {
                var result = orchestration.PutAsync(collectionName, string.Empty, item).Result;
            }
            catch (AggregateException ex)
            {
                var inner = ex.InnerExceptions.First() as ArgumentNullException;
                Assert.IsTrue(inner?.ParamName == "key");
                return;
            }

            orchestration.DeleteCollection(collectionName);
            Assert.Fail("No Exception Thrown");
        }
예제 #30
0
        public void PutIfNoneMatchWithNoKey()
        {
            var item = new TestData {Id = 77, Value = "Test Value 77"};

            try
            {
                _orchestrate.PutIfNoneMatch(CollectionName, string.Empty, item);
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "key");
                return;
            }

            Assert.Fail("No Exception Thrown");
        }