public void Issue_No34_MapAttributesToProperties()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
            Database.CreateTestCollection(Database.TestEdgeCollectionName, ACollectionType.Edge);
            var db = new ADatabase(Database.Alias);

            var vertex1 = new IssueNo34Entity
            {
                Key = "5",
                Foo = "some string value",
                Bar = 12345
            };

            var createResult1 = db.Document.Create(Database.TestDocumentCollectionName, vertex1);

            Assert.IsTrue(createResult1.Success);
            Assert.IsTrue(createResult1.HasValue);
            Assert.AreEqual(vertex1.Key, createResult1.Value.Key());

            var getResult1 = db.Document.Get <IssueNo34Entity>(createResult1.Value.ID());

            Assert.IsTrue(getResult1.Success);
            Assert.IsTrue(getResult1.HasValue);
            Assert.AreEqual(vertex1.Key, getResult1.Value.Key);
            Assert.AreEqual(vertex1.Foo, getResult1.Value.Foo);
            Assert.AreEqual(vertex1.Bar, getResult1.Value.Bar);

            var vertex2 = new IssueNo34Entity
            {
                Key = "8",
                Foo = "some other string value",
                Bar = 67890
            };

            var createResult2 = db.Document.Create(Database.TestDocumentCollectionName, vertex2);

            Assert.IsTrue(createResult2.Success);
            Assert.IsTrue(createResult2.HasValue);
            Assert.AreEqual(vertex2.Key, createResult2.Value.Key());

            var getResult2 = db.Document.Get <IssueNo34Entity>(createResult2.Value.ID());

            Assert.IsTrue(getResult2.Success);
            Assert.IsTrue(getResult2.HasValue);
            Assert.AreEqual(vertex2.Key, getResult2.Value.Key);
            Assert.AreEqual(vertex2.Foo, getResult2.Value.Foo);
            Assert.AreEqual(vertex2.Bar, getResult2.Value.Bar);

            var edge = new IssueNo34Entity
            {
                From = createResult1.Value.ID(),
                To   = createResult2.Value.ID(),
                Key  = "10",
                Foo  = "edge string value",
                Bar  = 13579
            };

            var createEdge = db
                             .Document
                             .ReturnNew()
                             .CreateEdge(Database.TestEdgeCollectionName, edge.From, edge.To, edge);

            Assert.IsTrue(createEdge.Success);
            Assert.IsTrue(createEdge.HasValue);
            Assert.AreEqual(edge.Key, createEdge.Value.Key());

            var getEdge = db.Document.Get <IssueNo34Entity>(createEdge.Value.ID());

            Assert.IsTrue(getEdge.Success);
            Assert.IsTrue(getEdge.HasValue);
            Assert.AreEqual(edge.From, getEdge.Value.From);
            Assert.AreEqual(edge.To, getEdge.Value.To);
            Assert.AreEqual(edge.Key, getEdge.Value.Key);
            Assert.AreEqual(edge.Foo, getEdge.Value.Foo);
            Assert.AreEqual(edge.Bar, getEdge.Value.Bar);

            var queryVertex1Result = db.Query
                                     .Aql($"FOR item IN {Database.TestDocumentCollectionName} FILTER item._key == \"{vertex1.Key}\" RETURN item")
                                     .ToObject <IssueNo34Entity>();

            Assert.IsTrue(queryVertex1Result.Success);
            Assert.IsTrue(queryVertex1Result.HasValue);
            Assert.AreEqual(vertex1.Key, queryVertex1Result.Value.Key);
            Assert.AreEqual(vertex1.Foo, queryVertex1Result.Value.Foo);
            Assert.AreEqual(vertex1.Bar, queryVertex1Result.Value.Bar);

            var queryVertex2Result = db.Query
                                     .Aql($"FOR item IN {Database.TestDocumentCollectionName} FILTER item._key == \"{vertex2.Key}\" RETURN item")
                                     .ToObject <IssueNo34Entity>();

            Assert.IsTrue(queryVertex2Result.Success);
            Assert.IsTrue(queryVertex2Result.HasValue);
            Assert.AreEqual(vertex2.Key, queryVertex2Result.Value.Key);
            Assert.AreEqual(vertex2.Foo, queryVertex2Result.Value.Foo);
            Assert.AreEqual(vertex2.Bar, queryVertex2Result.Value.Bar);

            var queryEdgeResult = db.Query
                                  .Aql($"FOR item IN {Database.TestEdgeCollectionName} FILTER item._key == \"{edge.Key}\" RETURN item")
                                  .ToObject <IssueNo34Entity>();

            Assert.IsTrue(queryEdgeResult.Success);
            Assert.IsTrue(queryEdgeResult.HasValue);
            Assert.AreEqual(edge.From, queryEdgeResult.Value.From);
            Assert.AreEqual(edge.To, queryEdgeResult.Value.To);
            Assert.AreEqual(edge.Key, queryEdgeResult.Value.Key);
            Assert.AreEqual(edge.Foo, queryEdgeResult.Value.Foo);
            Assert.AreEqual(edge.Bar, queryEdgeResult.Value.Bar);
        }
示例#2
0
        public void Issue_No34_MapAttributesToProperties()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
            Database.CreateTestCollection(Database.TestEdgeCollectionName, ACollectionType.Edge);
            var db = new ADatabase(Database.Alias);

            var vertex1 = new IssueNo34Entity
            {
                Key = "5",
                Foo = "some string value",
                Bar = 12345
            };

            var createResult1 = db.Document.Create(Database.TestDocumentCollectionName, vertex1);

            Assert.IsTrue(createResult1.Success);
            Assert.IsTrue(createResult1.HasValue);
            Assert.AreEqual(vertex1.Key, createResult1.Value.Key());

            var getResult1 = db.Document.Get<IssueNo34Entity>(createResult1.Value.ID());

            Assert.IsTrue(getResult1.Success);
            Assert.IsTrue(getResult1.HasValue);
            Assert.AreEqual(vertex1.Key, getResult1.Value.Key);
            Assert.AreEqual(vertex1.Foo, getResult1.Value.Foo);
            Assert.AreEqual(vertex1.Bar, getResult1.Value.Bar);

            var vertex2 = new IssueNo34Entity
            {
                Key = "8",
                Foo = "some other string value",
                Bar = 67890
            };

            var createResult2 = db.Document.Create(Database.TestDocumentCollectionName, vertex2);

            Assert.IsTrue(createResult2.Success);
            Assert.IsTrue(createResult2.HasValue);
            Assert.AreEqual(vertex2.Key, createResult2.Value.Key());

            var getResult2 = db.Document.Get<IssueNo34Entity>(createResult2.Value.ID());

            Assert.IsTrue(getResult2.Success);
            Assert.IsTrue(getResult2.HasValue);
            Assert.AreEqual(vertex2.Key, getResult2.Value.Key);
            Assert.AreEqual(vertex2.Foo, getResult2.Value.Foo);
            Assert.AreEqual(vertex2.Bar, getResult2.Value.Bar);

            var edge = new IssueNo34Entity
            {
                From = createResult1.Value.ID(),
                To = createResult2.Value.ID(),
                Key = "10",
                Foo = "edge string value",
                Bar = 13579
            };

            var createEdge = db
                .Document
                .ReturnNew()
                .CreateEdge(Database.TestEdgeCollectionName, edge.From, edge.To, edge);

            Assert.IsTrue(createEdge.Success);
            Assert.IsTrue(createEdge.HasValue);
            Assert.AreEqual(edge.Key, createEdge.Value.Key());

            var getEdge = db.Document.Get<IssueNo34Entity>(createEdge.Value.ID());

            Assert.IsTrue(getEdge.Success);
            Assert.IsTrue(getEdge.HasValue);
            Assert.AreEqual(edge.From, getEdge.Value.From);
            Assert.AreEqual(edge.To, getEdge.Value.To);
            Assert.AreEqual(edge.Key, getEdge.Value.Key);
            Assert.AreEqual(edge.Foo, getEdge.Value.Foo);
            Assert.AreEqual(edge.Bar, getEdge.Value.Bar);

            var queryVertex1Result = db.Query
                .Aql($"FOR item IN {Database.TestDocumentCollectionName} FILTER item._key == \"{vertex1.Key}\" RETURN item")
                .ToObject<IssueNo34Entity>();

            Assert.IsTrue(queryVertex1Result.Success);
            Assert.IsTrue(queryVertex1Result.HasValue);
            Assert.AreEqual(vertex1.Key, queryVertex1Result.Value.Key);
            Assert.AreEqual(vertex1.Foo, queryVertex1Result.Value.Foo);
            Assert.AreEqual(vertex1.Bar, queryVertex1Result.Value.Bar);

            var queryVertex2Result = db.Query
                .Aql($"FOR item IN {Database.TestDocumentCollectionName} FILTER item._key == \"{vertex2.Key}\" RETURN item")
                .ToObject<IssueNo34Entity>();

            Assert.IsTrue(queryVertex2Result.Success);
            Assert.IsTrue(queryVertex2Result.HasValue);
            Assert.AreEqual(vertex2.Key, queryVertex2Result.Value.Key);
            Assert.AreEqual(vertex2.Foo, queryVertex2Result.Value.Foo);
            Assert.AreEqual(vertex2.Bar, queryVertex2Result.Value.Bar);

            var queryEdgeResult = db.Query
                .Aql($"FOR item IN {Database.TestEdgeCollectionName} FILTER item._key == \"{edge.Key}\" RETURN item")
                .ToObject<IssueNo34Entity>();

            Assert.IsTrue(queryEdgeResult.Success);
            Assert.IsTrue(queryEdgeResult.HasValue);
            Assert.AreEqual(edge.From, queryEdgeResult.Value.From);
            Assert.AreEqual(edge.To, queryEdgeResult.Value.To);
            Assert.AreEqual(edge.Key, queryEdgeResult.Value.Key);
            Assert.AreEqual(edge.Foo, queryEdgeResult.Value.Foo);
            Assert.AreEqual(edge.Bar, queryEdgeResult.Value.Bar);
        }