本文整理汇总了C#中TestDatabaseContext类的典型用法代码示例。如果您正苦于以下问题:C# TestDatabaseContext类的具体用法?C# TestDatabaseContext怎么用?C# TestDatabaseContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDatabaseContext类属于命名空间,在下文中一共展示了TestDatabaseContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateVertexSet
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);
}
}
}
示例2: ShouldCreateDocumentClassSet
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"));
}
}
}
示例3: ShouldCreateClassCluster
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);
}
}
}
示例4: ShouldCreateDocumentFromObject
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);
}
}
}
示例5: Init
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();
}
示例6: GitHub_issue23
public GitHub_issue23()
{
_context = new TestDatabaseContext();
_database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
_database.Create.Class<DemoEmployee>().Run();
}
示例7: ShouldExecuteSimpleGremlinQuery
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");
}
}
}
示例8: Init
public void Init()
{
_context = new TestDatabaseContext();
_database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
_database.Create.Class<Person>().Run();
}
示例9: ShouldInsertDocumentInto
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"));
}
}
}
示例10: ProblemDeseralizingObjectWithDateTimeFields_31
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);
}
}
示例11: ShouldCreateEdgeFromOEdge
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"));
}
}
}
示例12: ShouldCreateVertexFromDocument
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"));
}
}
}
示例13: ShouldDeleteVertexFromDocumentOrid
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);
}
}
}
示例14: ShouldRetrieveRecordMetadata
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);
}
}
}
示例15: ShouldFetchLinkedDocumentsFromSimpleQuery
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"));
}
}