Пример #1
0
 public void Init()
 {
     Database.CreateTestDatabase(Database.TestDatabaseGeneral);
     db = Database.GetTestDatabase();
     List<ArangoGraphEdgeDefinition> eds = new List<ArangoGraphEdgeDefinition>();
     ed1 = new ArangoGraphEdgeDefinition(
         edgeCol1,
         new List<String>{fromCol1, fromCol2},
         new List<String>{toCol1, toCol2}
     );
     eds.Add(ed1);
     ed2 = new ArangoGraphEdgeDefinition(
         edgeCol2,
         new List<String>{fromCol2, fromCol3},
         new List<String>{toCol2, toCol3}
     );
     eds.Add(ed2);
     List<String> vertexCollections = new List<String>();
     vertexCollections.Add(vertexCol1);
     vertexCollections.Add(vertexCol2);
     vertexCollections.Add(vertexCol3);
     g = db.Graph.Create(graphName, eds, vertexCollections);
 }
        public void Should_create_and_get_document_from_object_with_dictionaries()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            var db = new ArangoDatabase(Database.Alias);

            var alert = new Alert();

            alert.PurchasedBy = new Dictionary<string, DateTime>();
            alert.PurchasedBy.Add("x", DateTime.Now);
            alert.PurchasedBy.Add("y", DateTime.Now);

            var person = new Person();
            person.FirstName = "Luke";
            person.LastName = "Skywalker";
            person.Age = 25;

            var p1 = new Person();
            p1.FirstName  = "Hans";
            p1.LastName = "Schmidth";
            p1.Age = 20;
            var relation1 = new Dictionary<string, Person>();
            relation1.Add("first", p1);

            alert.Relations = new Dictionary<string, Dictionary<string, Person>>();
            alert.Relations.Add("first-relation", relation1);

            db.Document.Create(Database.TestDocumentCollectionName, alert);

            var getResult = db.Document.Get<Alert>(alert.ThisIsId);

            Assert.AreEqual(0, getResult.StatusCode);
            Assert.AreEqual(true, getResult is Alert);
            Assert.AreEqual(2, getResult.PurchasedBy.Count);
            Assert.AreEqual(true, getResult.PurchasedBy.ContainsKey("x"));
            Assert.AreEqual(true, getResult.PurchasedBy.ContainsKey("y"));

            Assert.AreEqual(alert.PurchasedBy, getResult.PurchasedBy);
            Assert.AreEqual(alert.Relations.Count, getResult.Relations.Count);
            Assert.AreEqual(alert.Relations.Keys, getResult.Relations.Keys);
            Assert.AreEqual(alert.Relations["first-relation"].Keys, getResult.Relations["first-relation"].Keys);
            Assert.AreEqual(alert.Relations["first-relation"]["first"].Age, getResult.Relations["first-relation"]["first"].Age);
            Assert.AreEqual(alert.Relations["first-relation"]["first"].FirstName, getResult.Relations["first-relation"]["first"].FirstName);
            Assert.AreEqual(alert.Relations["first-relation"]["first"].LastName, getResult.Relations["first-relation"]["first"].LastName);
        }
Пример #3
0
 public void Init()
 {
     Database.CreateTestDatabase(Database.TestDatabaseGeneral);
     db = Database.GetTestDatabase();
 }
Пример #4
0
        public static void Main(string[] args)
        {
            ArangoClient.AddConnection(
                "localhost",
                8529,
                false,
                "test",
                "test"
            );

            var db = new ArangoDatabase("test");

            var document = db.Document.Get("Usersasfd/21857976");

            System.Console.WriteLine(document.String("_id"));
            System.Console.WriteLine(document.String("_key"));
            System.Console.WriteLine(document.String("_rev"));

            /*ArangoCollection collection = db.Collection.Get("Users");

            System.Console.WriteLine(collection.Id);
            System.Console.WriteLine(collection.Name);
            System.Console.WriteLine(collection.Status);
            System.Console.WriteLine(collection.Type);*/

            /*ArangoCollection col1 = new ArangoCollection();
            col1.Name = "latif";
            col1.Type = ArangoCollectionType.Edge;
            col1.WaitForSync = true;
            col1.JournalSize = 64000;

            db.Collection.Create(col1);

            System.Console.WriteLine(col1.Id);
            System.Console.WriteLine(col1.Name);
            System.Console.WriteLine(col1.Status);
            System.Console.WriteLine(col1.Type);

            System.Console.WriteLine(db.Collection.Delete(col1.Name));*/

            /*string json = @"{
                ""integer"": 12345,
                ""_foo"": ""bar"",
                ""embedded"": {
                    ""bar"": ""baz""
                },
                ""array"": [1, 2, 3, 4, 5],
                ""complex"": [{""x"":111,""y"":222},{""y"":333}]
            }";*/

            /*var json = "{\"null\":null,\"embedded\":{\"null\":null}}";

            var doc = new ArangoDocument(json);

            System.Console.WriteLine(JsonConvert.SerializeObject(doc, Formatting.Indented));

            /*Dictionary<string, object> foo = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);

            foreach (KeyValuePair<string, object> item in foo)
            {
                System.Console.WriteLine("{0} {1} {2}", item.Key, item.Value, item.Value.GetType());
            }

            System.Console.WriteLine("{0} {1}", ((JObject)foo["embedded"])["bar"], ((JObject)foo["embedded"]).Type);*/

            /*Dictionary<string, object> bar = new Dictionary<string, object>();

            bar.Add("foo", "bar");
            bar.Add("int", 123);
            bar.Add("emb", foo);
            bar.Add("arr", new string[] {"a", "b", "c"});

            System.Console.WriteLine(JsonConvert.SerializeObject(bar, Formatting.Indented));*/

            System.Console.ReadLine();
        }