示例#1
0
        public void ShouldInsertDocumentIntoCluster()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestClass")
                    .Run();

                    database
                    .Create.Cluster("TestCluster", OClusterType.Physical)
                    .Run();

                    database.Command("alter class TestClass addcluster TestCluster");

                    ODocument document = new ODocument()
                                         .SetField("foo", "foo string value")
                                         .SetField("bar", 12345);

                    ODocument insertedDocument = database
                                                 .Insert(document)
                                                 .Into("TestClass")
                                                 .Cluster("TestCluster")
                                                 .Run();

                    Assert.IsTrue(insertedDocument.ORID != null);
                    Assert.AreEqual(insertedDocument.OClassName, "TestClass");
                    Assert.AreEqual(insertedDocument.GetField <string>("foo"), document.GetField <string>("foo"));
                    Assert.AreEqual(insertedDocument.GetField <int>("bar"), document.GetField <int>("bar"));
                }
            }
        }
示例#2
0
        public void GetWorkItem_OnValidRequest_ReturnsWorkItem()
        {
            // ARRANGE
            DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>()
                                                             .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                                             .Options;
            IDatabaseContext   dbContext  = new TestDatabaseContext(options);
            WorkItemRepository repository = new WorkItemRepository(dbContext);
            WorkItemConverter  converter  = new WorkItemConverter(dbContext);

            WorkItem workItem = new WorkItem()
            {
                Description          = Guid.NewGuid().ToString(),
                Name                 = Guid.NewGuid().ToString(),
                WorkItemEnd          = DateTime.Now,
                WorkItemStart        = DateTime.Now,
                WorkItemCollectionId = 1
            };

            dbContext.WorkItems.Add(workItem);

            dbContext.SaveChanges();

            // ACT
            WorkItemPublic result = repository.GetWorkItem(1);

            // ASSERT
            result.Should().BeEquivalentTo <WorkItemPublic>(converter.Convert(workItem));
        }
示例#3
0
 private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase)
 {
     using (var databaseContext = testDatabase.CreateContext())
     {
         await databaseContext.CreateTestBlogAsync(UserId.Value, BlogId.Value);
     }
 }
        public void ShouldInsertObject()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions))
                {
                    // prerequisites
                    database
                    .Create.Class <TestProfileClass>()
                    .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name    = "Johny";
                    profile.Surname = "Bravo";

                    TestProfileClass insertedDocument = database
                                                        .Insert(profile)
                                                        .Run <TestProfileClass>();

                    Assert.IsTrue(insertedDocument.ORID != null);
                    Assert.AreEqual(insertedDocument.OClassName, typeof(TestProfileClass).Name);
                    Assert.AreEqual(insertedDocument.Name, profile.Name);
                    Assert.AreEqual(insertedDocument.Surname, profile.Surname);
                }
            }
        }
        public void ShouldInsertDocumentInto()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions))
                {
                    // prerequisites
                    database
                    .Create.Class("TestClass")
                    .Run();

                    ODocument document = new ODocument()
                                         .SetField("foo", "foo string value")
                                         .SetField("bar", 12345);

                    ODocument insertedDocument = database
                                                 .Insert(document)
                                                 .Into("TestClass")
                                                 .Run();

                    Assert.IsTrue(insertedDocument.ORID != null);
                    Assert.AreEqual(insertedDocument.OClassName, "TestClass");
                    Assert.AreEqual(insertedDocument.GetField <string>("foo"), document.GetField <string>("foo"));
                    Assert.AreEqual(insertedDocument.GetField <int>("bar"), document.GetField <int>("bar"));
                }
            }
        }
        private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                await databaseContext.CreateTestEntitiesAsync(CreatorId.Value, ChannelId.Value, QueueId.Value, BlogId.Value);

                await databaseContext.SaveChangesAsync();

                var post = PostTests.UniqueFileOrImage(Random);
                post.ChannelId = ChannelId.Value;
                post.Id        = PostId.Value;
                await databaseContext.Database.Connection.InsertAsync(post);

                await this.CreateUserAsync(databaseContext, UnsubscribedUserId);

                await this.CreateUserAsync(databaseContext, SubscribedUserId);

                await this.CreateUserAsync(databaseContext, GuestListUserId);

                var channelSubscriptions = new List <ChannelSubscription>();
                var freeAccessUsers      = new List <FreeAccessUser>();

                channelSubscriptions.Add(new ChannelSubscription(ChannelId.Value, null, SubscribedUserId.Value, null, ChannelPrice, Now, Now));

                freeAccessUsers.Add(new FreeAccessUser(BlogId.Value, GuestListUserId.Value + "@test.com"));

                await databaseContext.Database.Connection.InsertAsync(channelSubscriptions);

                await databaseContext.Database.Connection.InsertAsync(freeAccessUsers);
            }
        }
示例#7
0
        private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var random = new Random();
                await databaseContext.CreateTestEntitiesAsync(CreatorId.Value, ChannelId.Value, QueueId.Value);

                await databaseContext.CreateTestFileWithExistingUserAsync(CreatorId.Value, FileId.Value);

                var post = PostTests.UniqueFileOrImage(random);
                post.Id             = PostId.Value;
                post.ChannelId      = ChannelId.Value;
                post.QueueId        = QueueId.Value;
                post.PreviewImageId = FileId.Value;
                post.CreationDate   = new SqlDateTime(post.CreationDate).Value;
                post.LiveDate       = new SqlDateTime(post.LiveDate).Value;
                await databaseContext.Database.Connection.InsertAsync(post);

                await databaseContext.Database.Connection.InsertAsync(new PostFile(PostId.Value, FileId.Value));

                await databaseContext.CreateTestUserAsync(UserId.Value, random);

                var comment = CommentTests.Unique(random);
                comment.Id     = CommentId.Value;
                comment.PostId = PostId.Value;
                comment.UserId = UserId.Value;
                await databaseContext.Database.Connection.InsertAsync(comment);

                var like = LikeTests.Unique(random);
                like.PostId = PostId.Value;
                like.UserId = UserId.Value;
                await databaseContext.Database.Connection.InsertAsync(like);
            }
        }
        public void ShouldCreateClassCluster()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    short clusterid1 = database
                        .Create
                        .Cluster("ClasterForTest1", OClusterType.None)
                        .Run();

                    short clusterid2 = database
                        .Create
                        .Cluster("ClasterForTest2", OClusterType.None)
                        .Run();

                    short classId1 = database
                        .Create.Class("TestClass1")
                        .Cluster(clusterid1)
                        .Run();

                    Assert.IsTrue(classId1 > 0);

                    short classId2 = database
                        .Create.Class("TestClass2")
                        .Cluster(clusterid2)
                        .Run();

                    Assert.AreEqual(classId1 + 1, classId2);
                }
            }
        }
示例#9
0
 private async Task CreatePostAsync(UserId newUserId, PostId newPostId, TestDatabaseContext testDatabase)
 {
     using (var databaseContext = testDatabase.CreateContext())
     {
         await databaseContext.CreateTestNoteAsync(newUserId.Value, newPostId.Value);
     }
 }
        public void ShouldCreateVertexSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestVertexClass")
                        .Extends<OVertex>()
                        .Run();

                    OVertex createdVertex = database
                        .Create.Vertex("TestVertexClass")
                        .Set("foo", "foo string value")
                        .Set("bar", 12345)
                        .Run();

                    Assert.IsTrue(createdVertex.ORID != null);
                    Assert.AreEqual(createdVertex.OClassName, "TestVertexClass");
                    Assert.AreEqual(createdVertex.GetField<string>("foo"), "foo string value");
                    Assert.AreEqual(createdVertex.GetField<int>("bar"), 12345);
                }
            }
        }
        public void ShouldCreateDocumentClassSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestClass")
                        .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestClass";
                    document
                        .SetField("foo", "foo string value")
                        .SetField("bar", 12345);

                    ODocument createdDocument = database
                        .Create.Document("TestClass")
                        .Set(document)
                        .Run();

                    Assert.NotNull(createdDocument.ORID);
                    Assert.Equal("TestClass", createdDocument.OClassName);
                    Assert.Equal(document.GetField<string>("foo"), createdDocument.GetField<string>("foo"));
                    Assert.Equal(document.GetField<int>("bar"), createdDocument.GetField<int>("bar"));
                }
            }
        }
        public void ShouldCreateDocumentFromObject()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class<TestProfileClass>()
                        .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name = "Johny";
                    profile.Surname = "Bravo";

                    TestProfileClass createdObject = database
                        .Create.Document(profile)
                        .Run<TestProfileClass>();

                    Assert.NotNull(createdObject.ORID);
                    Assert.Equal(typeof(TestProfileClass).Name, createdObject.OClassName);
                    Assert.Equal(profile.Name, createdObject.Name);
                    Assert.Equal(profile.Surname, createdObject.Surname);
                }
            }
        }
示例#13
0
        public void ProblemDeseralizingObjectWithDateTimeFields_31()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    var startRecords = database.CountRecords;

                    // explicitly setting the timezone to UTC instead of the JVM default timezone
                    // FIXME: this is a work around for now
                    database.Command("ALTER DATABASE TIMEZONE UTC");
                    database.Create.Class <File>().Extends <OVertex>().CreateProperties().Run();

                    var dateTime = DateTime.UtcNow;
                    // OrientDB truncates milliseconds, so do so here for a proper comparison
                    dateTime = dateTime.AddTicks(-(dateTime.Ticks % TimeSpan.TicksPerSecond));

                    database.Insert(new File
                    {
                        Filename = "myfile",
                        Created  = dateTime
                    }).Run();

                    var doc  = database.Select().From <File>().ToList().First();
                    var file = doc.To <File>();

                    // FIXME: the time zone is off
                    Assert.That(file.Created, Is.EqualTo(dateTime));

                    var endRecords = database.CountRecords;
                    Assert.AreEqual(startRecords + 1, endRecords);
                }
        }
示例#14
0
        public void TestLoadNoFetchPlan()
        {
            using (var testContext = new TestDatabaseContext())
                using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestClass")
                    .Run();

                    ODocument document = new ODocument()
                                         .SetField("foo", "foo string value")
                                         .SetField("bar", 12345);

                    ODocument insertedDocument = database
                                                 .Insert(document)
                                                 .Into("TestClass")
                                                 .Run();
                    var loaded = database.Load.ORID(insertedDocument.ORID).Run();
                    Assert.AreEqual("TestClass", loaded.OClassName);
                    Assert.AreEqual(document.GetField <string>("foo"), loaded.GetField <string>("foo"));
                    Assert.AreEqual(document.GetField <int>("bar"), loaded.GetField <int>("bar"));
                    Assert.AreEqual(insertedDocument.ORID, loaded.ORID);
                }
        }
 public void Init()
 {
     _context = new TestDatabaseContext();
     _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
     _database.Create.Class("TestVertex").Run();
     _database.Create.Property("_datetime", OType.DateTime).Class("TestVertex").Run();
 }
示例#16
0
        public void ShouldCreateClassCluster()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    short clusterid1 = database
                                       .Create
                                       .Cluster("ClasterForTest1", OClusterType.None)
                                       .Run();

                    short clusterid2 = database
                                       .Create
                                       .Cluster("ClasterForTest2", OClusterType.None)
                                       .Run();

                    short classId1 = database
                                     .Create.Class("TestClass1")
                                     .Cluster(clusterid1)
                                     .Run();

                    Assert.IsTrue(classId1 > 0);

                    short classId2 = database
                                     .Create.Class("TestClass2")
                                     .Cluster(clusterid2)
                                     .Run();

                    Assert.AreEqual(classId1 + 1, classId2);
                }
            }
        }
        public void ShouldExecuteSimpleGremlinQuery()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    OVertex vertex1 = database
                        .Create.Vertex<OVertex>()
                        .Set("Foo", "foo string value 1")
                        .Set("Bar", 12345)
                        .Run();

                    OVertex vertex2 = database
                        .Create.Vertex<OVertex>()
                        .Set("Foo", "foo string value 2")
                        .Set("Bar", 54321)
                        .Run();

                    OEdge edge1 = database
                        .Create.Edge<OEdge>()
                        .From(vertex1)
                        .To(vertex2)
                        .Set("Foo", "foo string value 3")
                        .Set("Bar", 123)
                        .Run();

                    List<ODocument> documents = database.Gremlin("g.V");
                }
            }
        }
        public void TestCreateManyVertices()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestVertexClass")
                    .Extends <OVertex>()
                    .Run();

                    for (int i = 0; i < 1000; i++)
                    {
                        OVertex testVertex = new OVertex();
                        testVertex.OClassName = "TestVertexClass";
                        testVertex.SetField("foo", "foo string value");
                        testVertex.SetField("bar", i);
                        database.Transaction.Add(testVertex);
                    }

                    database.Transaction.Commit();


                    var createdVertices = database.Select().From("V").ToList();
                    Assert.AreEqual(1000, createdVertices.Count);

                    for (int i = 0; i < 1000; i++)
                    {
                        Assert.AreEqual(i, createdVertices[i].GetField <int>("bar"));
                    }
                }
            }
        }
        public void ShouldFetchLinkedDocumentsFromSimpleQuery()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
            {
                database.Create.Class("Owner").Extends("V").Run();
                database.Create.Class("Computer").Extends("V").Run();
                var owner = new ODocument { OClassName = "Owner" };

                owner.SetField<String>("name", "Shawn");

                owner = database.Create.Vertex(owner).Run();

                var computer = new ODocument { OClassName = "Computer" };

                computer.SetField<ORID>("owner", owner.ORID);
                database.Create.Vertex(computer).Run();

                computer = database.Query("SELECT FROM Computer", "*:-1").FirstOrDefault();

                Assert.That(database.ClientCache.ContainsKey(computer.GetField<ORID>("owner")));

                var document = database.ClientCache[computer.GetField<ORID>("owner")];
                Assert.That(document.GetField<string>("name"), Is.EqualTo("Shawn"));
            }
        }
 public void Dispose()
 {
     context.Dispose();
     context = null;
     database.Dispose();
     database = null;
 }
        public void ShouldDeleteDocumentFromDocumentOrid()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestClass")
                        .Run();

                    ODocument document1 = database
                        .Create.Document("TestClass")
                        .Set("foo", "foo string value1")
                        .Set("bar", 12345)
                        .Run();

                    ODocument document2 = database
                        .Create.Document("TestClass")
                        .Set("foo", "foo string value2")
                        .Set("bar", 54321)
                        .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestClass";

                    int documentsDeleted = database
                        .Delete.Document(document2)
                        .Run();

                    Assert.AreEqual(documentsDeleted, 1);
                }
            }
        }
示例#22
0
        public void ShouldDeleteVertexFromDocumentOrid()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestVertexClass")
                    .Extends <OVertex>()
                    .Run();

                    ODocument vertex1 = database
                                        .Create.Vertex("TestVertexClass")
                                        .Set("foo", "foo string value1")
                                        .Set("bar", 12345)
                                        .Run();

                    ODocument vertex2 = database
                                        .Create.Vertex("TestVertexClass")
                                        .Set("foo", "foo string value2")
                                        .Set("bar", 54321)
                                        .Run();

                    int documentsDeleted = database
                                           .Delete.Vertex(vertex2)
                                           .Run();

                    Assert.AreEqual(documentsDeleted, 1);
                }
            }
        }
        public void ShouldCreateVertexSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestVertexClass")
                    .Extends <OVertex>()
                    .Run();

                    OVertex createdVertex = database
                                            .Create.Vertex("TestVertexClass")
                                            .Set("foo", "foo string value")
                                            .Set("bar", 12345)
                                            .Run();

                    Assert.NotNull(createdVertex.ORID);
                    Assert.Equal("TestVertexClass", createdVertex.OClassName);
                    Assert.Equal("foo string value", createdVertex.GetField <string>("foo"));
                    Assert.Equal(12345, createdVertex.GetField <int>("bar"));
                }
            }
        }
        public void ShouldDeleteVertexFromObjectOrid()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class<TestProfileClass>()
                        .Extends<OVertex>()
                        .Run();

                    TestProfileClass vertex1 = database
                        .Create.Vertex<TestProfileClass>()
                        .Set("Name", "Johny")
                        .Set("Surname", "Bravo")
                        .Run<TestProfileClass>();

                    TestProfileClass vertex2 = database
                        .Create.Vertex<TestProfileClass>()
                        .Set("Name", "Julia")
                        .Set("Surname", "Bravo")
                        .Run<TestProfileClass>();

                    int documentsDeleted = database
                        .Delete.Vertex(vertex2)
                        .Run();

                    Assert.AreEqual(documentsDeleted, 1);
                }
            }
        }
 public void Dispose()
 {
     context.Dispose();
     context = null;
     database.Dispose();
     database = null;
 }
示例#26
0
        public void Init()
        {
            _context  = new TestDatabaseContext();
            _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);

            _database.Create.Class <Person>().Run();
        }
        public void ShouldCreateVertexFromDocument()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    // prerequisites
                    database
                    .Create.Class("TestVertexClass")
                    .Extends <OVertex>()
                    .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestVertexClass";
                    document
                    .SetField("foo", "foo string value")
                    .SetField("bar", 12345);

                    OVertex createdVertex = database
                                            .Create.Vertex(document)
                                            .Run();

                    Assert.IsTrue(createdVertex.ORID != null);
                    Assert.AreEqual(createdVertex.OClassName, "TestVertexClass");
                    Assert.AreEqual(createdVertex.GetField <string>("foo"), document.GetField <string>("foo"));
                    Assert.AreEqual(createdVertex.GetField <int>("bar"), document.GetField <int>("bar"));
                }
            }
        }
        public void ShouldCreateVertexFromObject()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    // prerequisites
                    database
                    .Create.Class <TestProfileClass>()
                    .Extends <OVertex>()
                    .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name    = "Johny";
                    profile.Surname = "Bravo";

                    TestProfileClass createdVertex = database
                                                     .Create.Vertex(profile)
                                                     .Run <TestProfileClass>();

                    Assert.IsTrue(createdVertex.ORID != null);
                    Assert.AreEqual(createdVertex.OClassName, typeof(TestProfileClass).Name);
                    Assert.AreEqual(createdVertex.Name, profile.Name);
                    Assert.AreEqual(createdVertex.Surname, profile.Surname);
                }
            }
        }
示例#29
0
        public void ShouldUpdateCluster()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    // prerequisites
                    database
                    .Create.Class("TestClass")
                    .Run();

                    database
                    .Create.Cluster("TestCluster", OClusterType.Physical)
                    .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestClass";
                    document
                    .SetField("foo", "foo string value")
                    .SetField("bar", 12345);

                    database
                    .Insert(document)
                    .Cluster("TestCluster")
                    .Run();

                    database
                    .Insert(document)
                    .Cluster("TestCluster")
                    .Run();

                    document
                    .SetField("bar", 54321)
                    .SetField("baz", "new baz value");

                    int documentsUpdated = database
                                           .Update(document)
                                           .Cluster("TestCluster")
                                           .Run();

                    Assert.AreEqual(documentsUpdated, 2);

                    List <ODocument> documents = database
                                                 .Select()
                                                 .From("cluster:TestCluster")
                                                 .ToList();

                    Assert.AreEqual(documents.Count, 2);

                    for (int i = 0; i < documents.Count; i++)
                    {
                        Assert.IsTrue(documents[i].ORID != null);
                        Assert.AreEqual(documents[i].OClassName, document.OClassName);
                        Assert.AreEqual(documents[i].GetField <string>("foo"), document.GetField <string>("foo"));
                        Assert.AreEqual(documents[i].GetField <int>("bar"), document.GetField <int>("bar"));
                        Assert.AreEqual(documents[i].GetField <string>("baz"), document.GetField <string>("baz"));
                    }
                }
            }
        }
 public GitHub_issue4()
 {
     _context  = new TestDatabaseContext();
     _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
     _database.Create.Class("TestVertex").Run();
     _database.Create.Property("_datetime", OType.DateTime).Class("TestVertex").Run();
 }
        public void ShouldCreateDocumentClassSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestClass")
                    .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestClass";
                    document
                    .SetField("foo", "foo string value")
                    .SetField("bar", 12345);

                    ODocument createdDocument = database
                                                .Create.Document("TestClass")
                                                .Set(document)
                                                .Run();

                    Assert.IsTrue(createdDocument.ORID != null);
                    Assert.AreEqual(createdDocument.OClassName, "TestClass");
                    Assert.AreEqual(createdDocument.GetField <string>("foo"), document.GetField <string>("foo"));
                    Assert.AreEqual(createdDocument.GetField <int>("bar"), document.GetField <int>("bar"));
                }
            }
        }
        public void TestCreateVerticesAndEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestVertexClass")
                    .Extends <OVertex>()
                    .Run();


                    var testVertex1 = CreateTestVertex(1);
                    var testVertex2 = CreateTestVertex(2);
                    database.Transaction.Add(testVertex1);
                    database.Transaction.Add(testVertex2);
                    testVertex1.OutE.Add(testVertex2.ORID);
                    testVertex2.InE.Add(testVertex1.ORID);


                    database.Transaction.Commit();

                    Assert.AreEqual(testVertex2.ORID, testVertex1.OutE.First());
                    Assert.AreEqual(testVertex1.ORID, testVertex2.InE.First());

                    var createdVertices = database.Select().From("V").ToList <OVertex>();
                    Assert.AreEqual(2, createdVertices.Count);

                    Assert.AreEqual(createdVertices[1].ORID, createdVertices[0].OutE.First());
                    Assert.AreEqual(createdVertices[0].ORID, createdVertices[1].InE.First());
                }
            }
        }
        public void ShouldCreateEdgeFromOEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OEdge edge = new OEdge();
                    edge.SetField("Foo", "foo string value");
                    edge.SetField("Bar", 12345);

                    OEdge createdEdge = database
                                        .Create.Edge(edge)
                                        .From(vertex1)
                                        .To(vertex2)
                                        .Run();

                    Assert.IsTrue(!string.IsNullOrEmpty(createdEdge.ORID.ToString()));
                    Assert.AreEqual(createdEdge.Label, "E");
                    Assert.AreEqual(createdEdge.OClassName, "E");
                    Assert.AreEqual(createdEdge.InV, vertex2.ORID);
                    Assert.AreEqual(createdEdge.OutV, vertex1.ORID);
                    Assert.AreEqual(createdEdge.GetField <string>("Foo"), edge.GetField <string>("Foo"));
                    Assert.AreEqual(createdEdge.GetField <int>("Bar"), edge.GetField <int>("Bar"));
                }
            }
        }
示例#34
0
        public void ShouldCreateVertexSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions))
                {
                    // prerequisites
                    database
                    .Create.Class("TestVertexClass")
                    .Extends <OVertex>()
                    .Run();

                    OVertex createdVertex = database
                                            .Create.Vertex("TestVertexClass")
                                            .Set("foo", "foo string value")
                                            .Set("bar", 12345)
                                            .Run();

                    Assert.IsTrue(createdVertex.ORID != null);
                    Assert.AreEqual(createdVertex.OClassName, "TestVertexClass");
                    Assert.AreEqual(createdVertex.GetField <string>("foo"), "foo string value");
                    Assert.AreEqual(createdVertex.GetField <int>("bar"), 12345);
                }
            }
        }
        public void ShouldReturnDatabaseToPoolAfterCloseAndDisposeCall()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                Assert.Equal(
                    TestConnection.GlobalTestDatabasePoolSize,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                    );

                ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);

                Assert.Equal(
                    TestConnection.GlobalTestDatabasePoolSize - 1,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                    );

                database.Close();

                Assert.Equal(
                    TestConnection.GlobalTestDatabasePoolSize,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                    );

                database.Dispose();

                Assert.Equal(
                    TestConnection.GlobalTestDatabasePoolSize,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                    );
            }
        }
        public void ShouldCreateVertexFromObject()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class <TestProfileClass>()
                    .Extends <OVertex>()
                    .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name    = "Johny";
                    profile.Surname = "Bravo";

                    TestProfileClass createdVertex = database
                                                     .Create.Vertex(profile)
                                                     .Run <TestProfileClass>();

                    Assert.NotNull(createdVertex.ORID);
                    Assert.Equal(typeof(TestProfileClass).Name, createdVertex.OClassName);
                    Assert.Equal(profile.Name, createdVertex.Name);
                    Assert.Equal(profile.Surname, createdVertex.Surname);
                }
            }
        }
        public void ShouldRetrieveRecordMetadata()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    database
                    .Create
                    .Class("TestClass")
                    .Run();

                    var document = new ODocument();
                    document.OClassName = "TestClass";
                    document.SetField("bar", 12345);
                    document.SetField("foo", "foo value 345");

                    var createdDocument = database
                                          .Create
                                          .Document(document)
                                          .Run();

                    var metadata = database
                                   .Metadata
                                   .ORID(createdDocument.ORID)
                                   .Run();
                    Assert.IsNotNull(metadata);
                    Assert.AreEqual(createdDocument.ORID, metadata.ORID);
                    Assert.AreEqual(createdDocument.OVersion, metadata.OVersion);
                }
            }
        }
        public void ShouldCreateDocumentFromObject()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class <TestProfileClass>()
                    .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name    = "Johny";
                    profile.Surname = "Bravo";

                    TestProfileClass createdObject = database
                                                     .Create.Document(profile)
                                                     .Run <TestProfileClass>();

                    Assert.IsTrue(createdObject.ORID != null);
                    Assert.AreEqual(createdObject.OClassName, typeof(TestProfileClass).Name);
                    Assert.AreEqual(createdObject.Name, profile.Name);
                    Assert.AreEqual(createdObject.Surname, profile.Surname);
                }
            }
        }
        public void ShouldRetrieveRecordMetadata()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    database
                        .Create
                        .Class("TestClass")
                        .Run();

                    var document = new ODocument();
                    document.OClassName = "TestClass";
                    document.SetField("bar", 12345);
                    document.SetField("foo", "foo value 345");

                    var createdDocument = database
                        .Create
                        .Document(document)
                        .Run();

                    var metadata = database
                        .Metadata
                        .ORID(createdDocument.ORID)
                        .Run();
                    Assert.IsNotNull(metadata);
                    Assert.AreEqual(createdDocument.ORID, metadata.ORID);
                    Assert.AreEqual(createdDocument.OVersion, metadata.OVersion);

                }
            }
        }
        public void TestLoadWithFetchPlanNoLinks()
        {
            using (var testContext = new TestDatabaseContext())
            {
                using (var database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    // prerequisites
                    database
                    .Create.Class("TestClass")
                    .Run();

                    ODocument document = new ODocument()
                                         .SetField("foo", "foo string value")
                                         .SetField("bar", 12345);

                    ODocument insertedDocument = database
                                                 .Insert(document)
                                                 .Into("TestClass")
                                                 .Run();
                    var loaded = database.Load.ORID(insertedDocument.ORID).FetchPlan("*:1").Run();
                    Assert.AreEqual(loaded.OClassName, "TestClass");
                    Assert.AreEqual(loaded.GetField <string>("foo"), document.GetField <string>("foo"));
                    Assert.AreEqual(loaded.GetField <int>("bar"), document.GetField <int>("bar"));
                    Assert.AreEqual(insertedDocument.ORID, loaded.ORID);
                }
            }
        }
        public GitHub_issue23()
        {
            _context = new TestDatabaseContext();
            _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
            _database.Create.Class<DemoEmployee>().Run();

        }
示例#42
0
        public void ShouldDeleteVertexFromObjectOrid()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class <TestProfileClass>()
                    .Extends <OVertex>()
                    .Run();

                    TestProfileClass vertex1 = database
                                               .Create.Vertex <TestProfileClass>()
                                               .Set("Name", "Johny")
                                               .Set("Surname", "Bravo")
                                               .Run <TestProfileClass>();

                    TestProfileClass vertex2 = database
                                               .Create.Vertex <TestProfileClass>()
                                               .Set("Name", "Julia")
                                               .Set("Surname", "Bravo")
                                               .Run <TestProfileClass>();

                    int documentsDeleted = database
                                           .Delete.Vertex(vertex2)
                                           .Run();

                    Assert.AreEqual(documentsDeleted, 1);
                }
            }
        }
        public void TestLoadWithFetchPlanNoLinks()
        {
            using (var testContext = new TestDatabaseContext())
            using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
            {
                // prerequisites
                database
                    .Create.Class("TestClass")
                    .Run();

                ODocument document = new ODocument()
                    .SetField("foo", "foo string value")
                    .SetField("bar", 12345);

                ODocument insertedDocument = database
                    .Insert(document)
                    .Into("TestClass")
                    .Run();
                var loaded = database.Load.ORID(insertedDocument.ORID).FetchPlan("*:1").Run();
                Assert.AreEqual("TestClass", loaded.OClassName);
                Assert.AreEqual(document.GetField<string>("foo"), loaded.GetField<string>("foo"));
                Assert.AreEqual(document.GetField<int>("bar"), loaded.GetField<int>("bar"));
                Assert.AreEqual(insertedDocument.ORID, loaded.ORID);

            }
        }
        public void ShouldReturnDatabaseToPoolAfterCloseAndDisposeCall()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                Assert.AreEqual(
                    TestConnection.GlobalTestDatabasePoolSize,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                );

                ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);

                Assert.AreEqual(
                    TestConnection.GlobalTestDatabasePoolSize - 1,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                );

                database.Close();

                Assert.AreEqual(
                    TestConnection.GlobalTestDatabasePoolSize,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                );

                database.Dispose();

                Assert.AreEqual(
                    TestConnection.GlobalTestDatabasePoolSize,
                    OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias)
                );
            }
        }
        public void ShouldCreateVertexFromDocument()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestVertexClass")
                        .Extends<OVertex>()
                        .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestVertexClass";
                    document
                        .SetField("foo", "foo string value")
                        .SetField("bar", 12345);

                    OVertex createdVertex = database
                        .Create.Vertex(document)
                        .Run();

                    Assert.IsNotNull(createdVertex.ORID);
                    Assert.AreEqual("TestVertexClass", createdVertex.OClassName);
                    Assert.AreEqual(document.GetField<string>("foo"), createdVertex.GetField<string>("foo"));
                    Assert.AreEqual(document.GetField<int>("bar"), createdVertex.GetField<int>("bar"));
                }
            }
        }
        public void ShouldDeleteVertexFromDocumentOrid()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestVertexClass")
                        .Extends<OVertex>()
                        .Run();

                    ODocument vertex1 = database
                        .Create.Vertex("TestVertexClass")
                        .Set("foo", "foo string value1")
                        .Set("bar", 12345)
                        .Run();

                    ODocument vertex2 = database
                        .Create.Vertex("TestVertexClass")
                        .Set("foo", "foo string value2")
                        .Set("bar", 54321)
                        .Run();

                    int documentsDeleted = database
                        .Delete.Vertex(vertex2)
                        .Run();

                    Assert.AreEqual(documentsDeleted, 1);
                }
            }
        }
        public void ShouldInsertDocumentInto()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestClass")
                        .Run();

                    ODocument document = new ODocument()
                        .SetField("foo", "foo string value")
                        .SetField("bar", 12345);

                    ODocument insertedDocument = database
                        .Insert(document)
                        .Into("TestClass")
                        .Run();

                    Assert.IsTrue(insertedDocument.ORID != null);
                    Assert.AreEqual(insertedDocument.OClassName, "TestClass");
                    Assert.AreEqual(insertedDocument.GetField<string>("foo"), document.GetField<string>("foo"));
                    Assert.AreEqual(insertedDocument.GetField<int>("bar"), document.GetField<int>("bar"));


                }
            }
        }
        public void ShouldDeleteDocumentFromObjectOClassName()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class<TestProfileClass>()
                        .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name = "Johny";
                    profile.Surname = "Bravo";

                    database
                        .Create.Document(profile)
                        .Run();

                    database
                        .Create.Document(profile)
                        .Run();

                    int documentsDeleted = database
                        .Delete.Document(profile)
                        .Run();

                    Assert.AreEqual(documentsDeleted, 2);
                }
            }
        }
        public void Init()
        {
            _context = new TestDatabaseContext();
            _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);

            _database.Create.Class<Person>().Run();
        }
        public void ShouldInsertObject()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class<TestProfileClass>()
                        .Run();

                    TestProfileClass profile = new TestProfileClass();
                    profile.Name = "Johny";
                    profile.Surname = "Bravo";

                    TestProfileClass insertedDocument = database
                        .Insert(profile)
                        .Run<TestProfileClass>();

                    Assert.IsTrue(insertedDocument.ORID != null);
                    Assert.AreEqual(insertedDocument.OClassName, typeof(TestProfileClass).Name);
                    Assert.AreEqual(insertedDocument.Name, profile.Name);
                    Assert.AreEqual(insertedDocument.Surname, profile.Surname);
                }
            }
        }
        public void ProblemDeseralizingObjectWithDateTimeFields_31()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
            {
                var startRecords = database.CountRecords;

                // explicitly setting the timezone to UTC instead of the JVM default timezone
                // FIXME: this is a work around for now
                database.Command("ALTER DATABASE TIMEZONE UTC");
                database.Create.Class<File>().Extends<OVertex>().CreateProperties().Run();

                var dateTime = DateTime.UtcNow;
                // OrientDB truncates milliseconds, so do so here for a proper comparison
                dateTime = dateTime.AddTicks( - (dateTime.Ticks % TimeSpan.TicksPerSecond));

                database.Insert(new File
                    {
                        Filename = "myfile",
                        Created = dateTime
                    }).Run();

                var doc = database.Select().From<File>().ToList().First();
                var file = doc.To<File>();

                // FIXME: the time zone is off
                Assert.That(file.Created, Is.EqualTo(dateTime));

                var endRecords = database.CountRecords;
                Assert.AreEqual(startRecords + 1, endRecords);
            }

        }
        public void ShouldCreateEdgeFromOEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    OVertex vertex1 = database
                        .Create.Vertex<OVertex>()
                        .Run();

                    OVertex vertex2 = database
                        .Create.Vertex<OVertex>()
                        .Run();

                    OEdge edge = new OEdge();
                    edge.SetField("Foo", "foo string value");
                    edge.SetField("Bar", 12345);

                    OEdge createdEdge = database
                        .Create.Edge(edge)
                        .From(vertex1)
                        .To(vertex2)
                        .Run();

                    Assert.NotNull(createdEdge.ORID);
                    Assert.Equal("E", createdEdge.Label);
                    Assert.Equal("E", createdEdge.OClassName);
                    Assert.Equal(vertex2.ORID, createdEdge.InV);
                    Assert.Equal(vertex1.ORID, createdEdge.OutV);
                    Assert.Equal(edge.GetField<string>("Foo"), createdEdge.GetField<string>("Foo"));
                    Assert.Equal(edge.GetField<int>("Bar"), createdEdge.GetField<int>("Bar"));
                }
            }
        }
        public void ShouldCreateProperty()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestClass")
                        .Extends<OVertex>()
                        .Run();


                    // Basic Test
                    foreach (var item in Enum.GetNames(typeof(OType)))
                    {
                        database.Create
                            .Property("_" + item.ToLower(), (OType)Enum.Parse(typeof(OType), item))
                            .Class("TestClass")
                            .Run();
                    }

                    var document = database.Query(_metadataQuery);

                    foreach (var item in Enum.GetNames(typeof(OType)))
                    {
                        var metadata = document.Find(d => d.GetField<string>("name") == "_" + item.ToLower());
                        validateMetadata(metadata, (OType)Enum.Parse(typeof(OType), item));
                    }

                    // Complex Test
                    database
                        .Create
                        .Property("_embededlist_with_type", OType.EmbeddedList)
                        .LinkedType(OType.Integer)
                        .Class("TestClass")
                        .Run();

                    database
                        .Create
                        .Property("_embededlist_with_class", OType.EmbeddedList)
                        .LinkedClass("OUser")
                        .Class("TestClass")
                        .Run();

                    document = database.Query(_metadataQuery);

                    var elwtMetadata = document.Find(d => d.GetField<string>("name") == "_embededlist_with_type");
                    validateMetadata(elwtMetadata, OType.EmbeddedList);
                    Assert.AreEqual(OType.Integer, (OType)elwtMetadata.GetField<int>("linkedType"));

                    var elwcMetadata = document.Find(d => d.GetField<string>("name") == "_embededlist_with_class");
                    validateMetadata(elwtMetadata, OType.EmbeddedList);
                    Assert.AreEqual("OUser", elwcMetadata.GetField<string>("linkedClass"));

                }
            }
        }
 public void ShouldReturnDatabaseSize()
 {
     using (var context = new TestDatabaseContext())
     using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
     {
         var size = database.Size;
         Assert.IsTrue(size > 0);
     }
 }
 public void ShouldCreateVertex()
 {
     using (var context = new TestDatabaseContext())
     using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
     {
         //var document = database.Command("create vertex set  bar=1").ToSingle();
         var d = database.Create.Vertex<OVertex>().Run();
     }
 }
        public GitHub_issue57()
        {
            _context = new TestDatabaseContext();
            _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);

            _database.Create.Class("TestVertex").Extends<OVertex>().Run();
            _database.Create.Class("TestEdge").Extends<OEdge>().Run();

        }
 public void ShouldLoadDatabaseProperties()
 {
     using (var context = new TestDatabaseContext())
     using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
     {
         var document = database.DatabaseProperties;
         Assert.That(document, Is.Not.Null);
         Assert.That(document.Keys.Count, Is.GreaterThan(0));
     }
 }
 public void TestDbList()
 {
     using (var context = new TestDatabaseContext())
     using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
     {
         OServer server = TestConnection.GetServer();
         Dictionary<string, ODatabaseInfo> databases = server.Databases();
         Assert.IsTrue(databases.Count > 0);
     }
 }
 public void ShouldLoadDatabaseProperties()
 {
     using (var context = new TestDatabaseContext())
     using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
     {
         var document = database.DatabaseProperties;
         Assert.NotNull(document);
         Assert.True(document.Keys.Count > 0);
     }
 }
        public void ShouldUpdateClassFromDocument()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestClass")
                        .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestClass";
                    document
                        .SetField("foo", "foo string value")
                        .SetField("bar", 12345);

                    database
                        .Insert(document)
                        .Run();

                    database
                        .Insert(document)
                        .Run();

                    document
                        .SetField("bar", 54321)
                        .SetField("baz", "new baz value");

                    int documentsUpdated = database
                        .Update(document)
                        .Run();

                    Assert.AreEqual(documentsUpdated, 2);

                    List<ODocument> documents = database
                        .Select()
                        .From("TestClass")
                        .ToList();

                    Assert.AreEqual(documents.Count, 2);

                    for (int i = 0; i < documents.Count; i++)
                    {
                        Assert.IsTrue(documents[i].ORID != null);
                        Assert.AreEqual(documents[i].OClassName, document.OClassName);
                        Assert.AreEqual(documents[i].GetField<string>("foo"), document.GetField<string>("foo"));
                        Assert.AreEqual(documents[i].GetField<int>("bar"), document.GetField<int>("bar"));
                        Assert.AreEqual(documents[i].GetField<string>("baz"), document.GetField<string>("baz"));
                    }
                }
            }
        }