本文整理汇总了C#中TestDatabaseContext类的典型用法代码示例。如果您正苦于以下问题:C# TestDatabaseContext类的具体用法?C# TestDatabaseContext怎么用?C# TestDatabaseContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDatabaseContext类属于命名空间,在下文中一共展示了TestDatabaseContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:25,代码来源:SqlCreateVertexTests.cs
示例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"));
}
}
}
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SqlCreateDocumentTests.cs
示例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);
}
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:32,代码来源:SqlCreateClassTests.cs
示例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);
}
}
}
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:SqlCreateDocumentTests.cs
示例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();
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:GitHub_issue4.cs
示例6: GitHub_issue23
public GitHub_issue23()
{
_context = new TestDatabaseContext();
_database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
_database.Create.Class<DemoEmployee>().Run();
}
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:GitHub_issue23.cs
示例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");
}
}
}
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:30,代码来源:GremlinTests.cs
示例8: Init
public void Init()
{
_context = new TestDatabaseContext();
_database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
_database.Create.Class<Person>().Run();
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:GitHub_issue62.cs
示例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"));
}
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SqlInsertTests.cs
示例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);
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:33,代码来源:GitHub_issue31.cs
示例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"));
}
}
}
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:34,代码来源:SqlCreateEdgeTests.cs
示例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"));
}
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SqlCreateVertexTests.cs
示例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);
}
}
}
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:32,代码来源:SqlDeleteVertexTests.cs
示例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);
}
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:32,代码来源:TestRecordMetadata.cs
示例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"));
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:SqlQueryTests.cs
示例16: ShouldReturnDatabaseToPoolAfterCloseAndDisposeCall
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)
);
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:31,代码来源:ConnectionPoolTests.cs
示例17: ShouldDeleteDocumentFromDocumentOrid
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);
}
}
}
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:34,代码来源:SqlDeleteDocumentTests.cs
示例18: ShouldDeleteDocumentFromObjectOClassName
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);
}
}
}
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:31,代码来源:SqlDeleteDocumentTests.cs
示例19: TestLoadWithFetchPlanNoLinks
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);
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:LoadRecordTests.cs
示例20: ShouldInsertObject
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);
}
}
}
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:SqlInsertTests.cs
注:本文中的TestDatabaseContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论