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")); } } } }
private static void ConnectionPoolTest() { OServer server = new OServer(Configuration["ConnectionStrings:DefaultConnection:Server"], int.Parse(Configuration["ConnectionStrings:DefaultConnection:Port"]), Configuration["ConnectionStrings:DefaultConnection:Username"], Configuration["ConnectionStrings:DefaultConnection:Password"]); if (server.DatabaseExist(Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], OStorageType.PLocal)) { server.DropDatabase(Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], OStorageType.PLocal); } server.CreateDatabase(Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], ODatabaseType.Graph, OStorageType.PLocal); using (ODatabase database = new ODatabase(Configuration["ConnectionStrings:DefaultConnection:Server"], int.Parse(Configuration["ConnectionStrings:DefaultConnection:Port"]), Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], ODatabaseType.Graph, Configuration["ConnectionStrings:DefaultConnection:Username"], Configuration["ConnectionStrings:DefaultConnection:Password"])) { database.Create.Class("Person").Run(); database.Insert().Into("Person").Set("Name", $"John").Set("LastName", $"Doe").Set("Age", 99).Run(); Parallel.For(0, 1000000, (i) => { ODocument document = database.Insert().Into("Person").Set("Name", $"John{i}").Set("LastName", $"Doe{i}").Set("Age", i).Run(); //System.Console.WriteLine(document.ORID); }); } }
public void ShouldUpdateOridSet() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document = new ODocument(); document.OClassName = "TestClass"; document .SetField("foo", "foo string value") .SetField("bar", 12345); ODocument document1 = database .Insert(document) .Run(); ODocument document2 = database .Insert(document) .Run(); document2 .SetField("bar", 54321) .SetField("baz", "new baz value"); int documentsUpdated = database .Update(document2.ORID) .Set(document2) .Run(); Assert.AreEqual(documentsUpdated, 1); List <ODocument> documents = database .Select() .From("TestClass") .Where("bar").Equals(54321) .ToList(); Assert.AreEqual(documents.Count, 1); for (int i = 0; i < documents.Count; i++) { Assert.AreEqual(documents[i].ORID, document2.ORID); Assert.AreEqual(documents[i].OClassName, document2.OClassName); Assert.AreEqual(documents[i].GetField <string>("foo"), document2.GetField <string>("foo")); Assert.AreEqual(documents[i].GetField <int>("bar"), document2.GetField <int>("bar")); Assert.AreEqual(documents[i].GetField <string>("baz"), document2.GetField <string>("baz")); } } } }
public void ShouldUpdateClass() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document = new ODocument(); document .SetField("foo", "foo string value") .SetField("bar", 12345); database .Insert(document) .Into("TestClass") .Run(); database .Insert(document) .Into("TestClass") .Run(); document .SetField("bar", 54321) .SetField("baz", "new baz value"); int documentsUpdated = database .Update(document) .Class("TestClass") .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, "TestClass"); 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 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")); } } } }
public void ShouldUpdateRecord() { 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 document1 = database .Insert(document) .Run(); ODocument document2 = database .Insert(document) .Run(); ODocument docToUpdate = new ODocument() .SetField("bar", 54321) .SetField("baz", "new baz value"); int documentsUpdated = database .Update(docToUpdate) .Record(document2.ORID) .Run(); Assert.AreEqual(documentsUpdated, 1); List <ODocument> documents = database .Select() .From("TestClass") .Where("bar").Equals(54321) .ToList(); Assert.AreEqual(documents.Count, 1); Assert.AreEqual(documents[0].ORID, document2.ORID); Assert.AreEqual(documents[0].OClassName, document2.OClassName); Assert.AreEqual(documents[0].GetField <string>("foo"), document2.GetField <string>("foo")); Assert.AreEqual(documents[0].GetField <int>("bar"), docToUpdate.GetField <int>("bar")); Assert.AreEqual(documents[0].GetField <string>("baz"), docToUpdate.GetField <string>("baz")); } } }
public void ShouldUpdateRecordUsingMerge() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument record1 = database.Insert("TestClass") .Content(TestConstants.CreateJson) .Run(); ODocument record2 = database.Insert("TestClass") .Content(TestConstants.CreateJson) .Run(); var recordsMerged = database.Update(record1.ORID) .Merge(TestConstants.MergeJson) .Run(); Assert.AreEqual(1, recordsMerged); List <ODocument> documents = database .Select() .From("TestClass") .Where("simpleString").Equals("TestString") .ToList(); Assert.AreEqual(2, documents.Count); documents = database .Select() .From("TestClass") .Where("embeddedObject.newProperty").Equals("NewValue") .ToList(); Assert.AreEqual(1, documents.Count); for (int i = 0; i < documents.Count; i++) { checkMergedContentAssertions(documents[i]); } } } }
public void ShouldUpdateClassFromObject() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS)) { // prerequisites database .Create.Class <TestProfileClass>() .Run(); TestProfileClass profile = new TestProfileClass(); profile.Name = "Johny"; database .Insert(profile) .Run(); database .Insert(profile) .Run(); profile.Name = "Julia"; profile.Surname = "Bravo"; int documentsUpdated = database .Update(profile) .Run(); Assert.AreEqual(documentsUpdated, 2); List <TestProfileClass> documents = database .Select() .From <TestProfileClass>() .ToList <TestProfileClass>(); Assert.AreEqual(documents.Count, 2); for (int i = 0; i < documents.Count; i++) { Assert.IsTrue(documents[i].ORID != null); Assert.AreEqual(documents[i].OClassName, typeof(TestProfileClass).Name); Assert.AreEqual(documents[i].Name, profile.Name); Assert.AreEqual(documents[i].Surname, profile.Surname); } } } }
public void ShouldUpdateClassFromObject() { 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"; database .Insert(profile) .Run(); database .Insert(profile) .Run(); profile.Name = "Julia"; profile.Surname = "Bravo"; int documentsUpdated = database .Update(profile) .Run(); Assert.AreEqual(documentsUpdated, 2); List<TestProfileClass> documents = database .Select() .From<TestProfileClass>() .ToList<TestProfileClass>(); Assert.AreEqual(documents.Count, 2); for (int i = 0; i < documents.Count; i++) { Assert.IsTrue(documents[i].ORID != null); Assert.AreEqual(documents[i].OClassName, typeof(TestProfileClass).Name); Assert.AreEqual(documents[i].Name, profile.Name); Assert.AreEqual(documents[i].Surname, profile.Surname); } } } }
public void ShouldInsertObjectUsingContentKeyword() { 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(typeof(TestProfileClass).Name) .Content("{\"Name\":\"Johny\", \"Surname\":\"Bravo\"}") .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 ShouldInsertObjectIntoUsingContentKeyword() { 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() .Into("TestClass") .Content("{\"bar\": 12345, \"foo\":\"foo string value\"}") .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 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 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 TestLoadNoFetchPlan() { using (var testContext = new TestDatabaseContext()) { using (var 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(); var loaded = database.Load.ORID(insertedDocument.ORID).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 void TestGermanFloatCulture() { var floatValue = "108,4"; float @float; #if DNX451 float.TryParse(floatValue, NumberStyles.Any, CultureInfo.GetCultureInfo("de-DE"), out @float); #elif DNXCORE50 CultureInfo germanCulture = new CultureInfo("de-DE"); float.TryParse(floatValue, NumberStyles.Any, germanCulture, out @float); #else float = 0f; #error No implementation for the target DNX #endif var doc = new ODocument { OClassName = "TestVertex" } .SetField("floatField", @float); var insertedDoc = _database.Insert(doc).Run(); Assert.NotNull(insertedDoc.ORID); Assert.Equal(doc.GetField <float>("@float"), insertedDoc.GetField <float>("@float")); }
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 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 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(); 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")); } } }
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.Equal("TestClass", loaded.OClassName); Assert.Equal(document.GetField <string>("foo"), loaded.GetField <string>("foo")); Assert.Equal(document.GetField <int>("bar"), loaded.GetField <int>("bar")); Assert.Equal(insertedDocument.ORID, loaded.ORID); } }
public void ShouldInsertDocumentInto() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase 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(); 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 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 ShouldUpdateRemoveFieldQuery() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", "foo string value1") .Set("bar", 11111) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", "foo string value2") .Set("bar", 12345) .Run(); int documentsUpdated = database .Update(document2) .Remove("bar") .Run(); Assert.AreEqual(documentsUpdated, 1); List <ODocument> documents = database .Select() .From("TestClass") .Where("foo").Equals("foo string value2") .ToList(); Assert.AreEqual(documents.Count, 1); Assert.AreEqual(documents[0].ORID, document2.ORID); Assert.AreEqual(documents[0].OClassName, document2.OClassName); Assert.AreEqual(documents[0].GetField <string>("foo"), document2.GetField <string>("foo")); Assert.IsFalse(documents[0].HasField("bar")); } } }
public static void AddDesktop(String name, String OS, String LanMacAddress) { ODatabase database = InitDB(); database.Insert().Into("Desktop").Set("name", name) .Set("OS", OS).Set("LanMacAddress", LanMacAddress).Run(); database.Close(); }
public void ShouldSelectFromDocumentOClassNameQuery() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", "foo string value1") .Set("bar", 12345) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", "foo string value2") .Set("bar", 54321) .Run(); ODocument document = new ODocument(); document.OClassName = "TestClass"; List<ODocument> documents = database .Select() .From(document) .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.IsTrue(documents[i].HasField("foo")); Assert.IsTrue(documents[i].HasField("bar")); } } } }
public void ShouldSelectFromDocumentOClassNameQuery() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", "foo string value1") .Set("bar", 12345) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", "foo string value2") .Set("bar", 54321) .Run(); ODocument document = new ODocument(); document.OClassName = "TestClass"; List <ODocument> documents = database .Select() .From(document) .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.IsTrue(documents[i].HasField("foo")); Assert.IsTrue(documents[i].HasField("bar")); } } } }
public static void AddServer(String name, String OS, String LanMacAddress, String Type, String Description) { ODatabase database = InitDB(); database.Insert().Into("Server").Set("name", name) .Set("OS", OS).Set("LanMacAddress", LanMacAddress) .Set("Type", Type).Set("Description", Description).Run(); database.Close(); }
public static void AddLaptop(String name, String OS, String LanMacAddress, String WiFiMacAddress, String WiFiNetworkName) { ODatabase database = InitDB(); database.Insert().Into("Laptop").Set("name", name) .Set("OS", OS).Set("LanMacAddress", LanMacAddress) .Set("WiFiMacAddress", WiFiMacAddress).Set("WiFiNetworkName", WiFiNetworkName).Run(); database.Close(); }
public async Task <List <EntityInstance> > AddRange(IEnumerable <EntityInstance> entities) { foreach (var entity in entities) { database.Insert(entity).Into("entities").Run(); } return(entities.ToList()); }
public void ShouldSelectToObjectList() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions)) { // prerequisites database .Create.Class <TestProfileClass>() .Run(); TestProfileClass document1 = database .Insert() .Into <TestProfileClass>() .Set("Name", "Johny") .Set("Surname", "Bravo") .Run <TestProfileClass>(); TestProfileClass document2 = database .Insert() .Into <TestProfileClass>() .Set("Name", "Johny") .Set("Surname", "Bravo") .Run <TestProfileClass>(); List <TestProfileClass> documents = database .Select() .From <TestProfileClass>() .ToList <TestProfileClass>(); Assert.AreEqual(documents.Count, 2); Assert.AreEqual(documents[0].ORID, document1.ORID); Assert.AreEqual(documents[0].OClassName, document1.OClassName); Assert.AreEqual(documents[0].Name, document1.Name); Assert.AreEqual(documents[0].Surname, document1.Surname); Assert.AreEqual(documents[1].ORID, document2.ORID); Assert.AreEqual(documents[1].OClassName, document2.OClassName); Assert.AreEqual(documents[1].Name, document2.Name); Assert.AreEqual(documents[1].Surname, document2.Surname); } } }
public void TestLoadWithFetchPlanWithLinks() { using (var testContext = new TestDatabaseContext()) { using (var 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(); for (int i = 0; i < 2; i++) { ODocument document2 = new ODocument() .SetField("foo", "bar string value") .SetField("bar", 23456); ODocument insertedDocument2 = database .Insert(document2) .Into("TestClass") .Run(); database.Create.Edge("E").From(insertedDocument).To(insertedDocument2).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 void ShouldSelectFromDocumentOrid() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.ConnectionOptions)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", "foo string value1") .Set("bar", 12345) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", "foo string value2") .Set("bar", 54321) .Run(); List <ODocument> documents = database .Select() .From(document2) .ToList(); Assert.AreEqual(documents.Count, 1); for (int i = 0; i < documents.Count; i++) { Assert.AreEqual(documents[i].ORID, document2.ORID); Assert.AreEqual(documents[i].OClassName, document2.OClassName); Assert.AreEqual(documents[i].GetField <string>("foo"), document2.GetField <string>("foo")); Assert.AreEqual(documents[i].GetField <int>("bar"), document2.GetField <int>("bar")); } } } }
public void ShouldSelectFromDocumentOrid() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", "foo string value1") .Set("bar", 12345) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", "foo string value2") .Set("bar", 54321) .Run(); List<ODocument> documents = database .Select() .From(document2) .ToList(); Assert.AreEqual(documents.Count, 1); for (int i = 0; i < documents.Count; i++) { Assert.AreEqual(documents[i].ORID, document2.ORID); Assert.AreEqual(documents[i].OClassName, document2.OClassName); Assert.AreEqual(documents[i].GetField<string>("foo"), document2.GetField<string>("foo")); Assert.AreEqual(documents[i].GetField<int>("bar"), document2.GetField<int>("bar")); } } } }
public void q_26790891() { Person luca = new Person(); luca.Residence = new Address { AddressLine1 = "PO 2456", AddressLine2 = "PO 1234" }; database.Insert <Person>(luca, database.Transaction); }
public void ShouldInsertValuesWithBackslash() { _database .Create.Class("TestClass") .Run(); ODocument document = new ODocument(); document.OClassName = "TestClass"; document .SetField("foo", "foo string value \\ test te5435ttrtr") .SetField("bar", 12345); ODocument insertedDocument = _database .Insert(document) .Run(); Assert.True(insertedDocument.ORID != null); Assert.Equal(insertedDocument.OClassName, "TestClass"); Assert.Equal(insertedDocument.GetField <string>("foo"), document.GetField <string>("foo")); Assert.Equal(insertedDocument.GetField <int>("bar"), document.GetField <int>("bar")); }
public static void AddSwitch(String name, String SerialNumber, String Manufacturer, int NumberOfPorts, int NumberOfTakenPorts) { List <String> MacAddressList = new List <string>(); ODatabase database = InitDB(); database.Insert().Into("Switch").Set("name", name) .Set("SerialNumber", SerialNumber) .Set("Manufacturer", Manufacturer) .Set("NumberOfPorts", NumberOfPorts).Set("NumberOfTakenPorts", NumberOfTakenPorts) .Set("MacAddressList", MacAddressList).Run(); database.Close(); }
public static void AddRouter(String name, String OS, String SerialNumber, String Manufacturer, String WiFiNetworkName, int NumberOfPorts, int NumberOfTakenPorts) { List <String> MacAddressList = new List <string>(); ODatabase database = InitDB(); database.Insert().Into("Router").Set("name", name) .Set("OS", OS).Set("SerialNumber", SerialNumber) .Set("Manufacturer", Manufacturer).Set("WiFiNetworkName", WiFiNetworkName) .Set("NumberOfPorts", NumberOfPorts).Set("NumberOfTakenPorts", NumberOfTakenPorts) .Set("MacAddressList", MacAddressList).Run(); database.Close(); }
public void TestGermanFloatCulture() { var floatValue = "108,4"; float @float; float.TryParse(floatValue, NumberStyles.Any, CultureInfo.GetCultureInfo("de-DE"), out @float); var doc = new ODocument { OClassName = "TestVertex" } .SetField("floatField", @float); var insertedDoc = _database.Insert(doc).Run(); Assert.NotNull(insertedDoc.ORID); Assert.Equal(doc.GetField <float>("@float"), insertedDoc.GetField <float>("@float")); }
public PreparedQueryTest() { _context = new TestDatabaseContext(); _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias); _database.Create.Class("Profile").Run(); var properties = new[]{ new {name="Michael",surname = "Blach"}, new {name="Shantaram",surname = "Gaikwad"}, new {name="Luca",surname = "Garulli"} }; foreach (var item in properties) { _database.Insert() .Into("Profile") .Set("name", item.name) .Set("surname", item.surname).Run(); } }
public void ShouldCreateRecordContainingSingleQuote() { using (TestDatabaseContext testContext = new TestDatabaseContext()) using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { if (!db.Schema.IsClassExist<TestClass>()) { db.Create.Class<TestClass>().CreateProperties<TestClass>().Run(); } db.Command("delete from TestClass"); var text = @"Jim'n"; var test = new TestClass() { SomeString = text }; db.Insert(test).Run(); var result = db.Select().From<TestClass>().ToList<TestClass>(); Assert.Equal(text, result.Single().SomeString); } }
public void GIVEN___EmployeeDictionaryType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read() { using (TestDatabaseContext testContext = new TestDatabaseContext()) using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { var employeeClassName = "EmployeeDictionaryType"; var clusterid = db.Create.Class(employeeClassName).Run(); var employee = new EmployeeDictionaryType(); employee.Id = Guid.NewGuid(); employee.Name = new Dictionary<string, string>(); employee.Name.Add("Andrew", "Andrew"); employee.Name.Add("Jack", "Jack"); employee.Ids = new Dictionary<Guid, Guid>(); employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid()); employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid()); employee.Age = new Dictionary<int, int>(); employee.Age.Add(1, 2); employee.Age.Add(2, 4); employee.Height = new Dictionary<short, short>(); employee.Height.Add(1, 2); employee.Height.Add(2, 4); employee.Tall = new Dictionary<long, long>(); employee.Tall.Add(1234567890123456789, 987654321098765432); employee.Tall.Add(987654321098765432, 1234567890123456789); employee.Childs = new Dictionary<int, EmployeeCommonType>(); employee.Childs.Add(1, new EmployeeCommonType() { Id = Guid.NewGuid() }); employee.Childs.Add(2, new EmployeeCommonType() { Id = Guid.NewGuid() }); employee.FavoriteColor = new Dictionary<Color, Color>(); employee.FavoriteColor.Add(Color.Red, Color.Red); employee.FavoriteColor.Add(Color.Blue, Color.Blue); var document = db.Insert(employee).Into(employeeClassName).Run(); var result = db.Query<EmployeeDictionaryType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault(); Assert.Equal(employee.Id, result.Id); Assert.True(result.Name.ContainsKey("Jack")); Assert.True(result.Name.ContainsKey("Andrew")); Assert.Equal(employee.Name["Jack"], result.Name["Jack"]); Assert.Equal(employee.Name["Andrew"], result.Name["Andrew"]); Assert.True(result.Ids.ContainsKey(employee.Ids.Keys.ToArray()[0])); Assert.True(result.Ids.ContainsKey(employee.Ids.Keys.ToArray()[1])); Assert.Equal(employee.Ids[employee.Ids.Keys.ToArray()[0]], result.Ids[employee.Ids.Keys.ToArray()[0]]); Assert.Equal(employee.Ids[employee.Ids.Keys.ToArray()[1]], result.Ids[employee.Ids.Keys.ToArray()[1]]); Assert.True(result.Age.ContainsKey(1)); Assert.True(result.Age.ContainsKey(2)); Assert.Equal(employee.Age[1], result.Age[1]); Assert.Equal(employee.Age[2], result.Age[2]); Assert.True(result.Height.ContainsKey(employee.Height.Keys.ToArray()[0])); Assert.True(result.Height.ContainsKey(employee.Height.Keys.ToArray()[1])); Assert.Equal(employee.Height[employee.Height.Keys.ToArray()[0]], result.Height[employee.Height.Keys.ToArray()[0]]); Assert.Equal(employee.Height[employee.Height.Keys.ToArray()[1]], result.Height[employee.Height.Keys.ToArray()[1]]); Assert.True(result.Tall.ContainsKey(employee.Tall.Keys.ToArray()[0])); Assert.True(result.Tall.ContainsKey(employee.Tall.Keys.ToArray()[1])); Assert.Equal(employee.Tall[employee.Tall.Keys.ToArray()[0]], result.Tall[employee.Tall.Keys.ToArray()[0]]); Assert.Equal(employee.Tall[employee.Tall.Keys.ToArray()[1]], result.Tall[employee.Tall.Keys.ToArray()[1]]); Assert.Equal(employee.Childs[1].Id, result.Childs[1].Id); Assert.Equal(employee.Childs[2].Id, result.Childs[2].Id); Assert.True(result.FavoriteColor.ContainsKey(Color.Red)); Assert.True(result.FavoriteColor.ContainsKey(Color.Blue)); Assert.Equal(employee.FavoriteColor[Color.Red], result.FavoriteColor[Color.Red]); Assert.Equal(employee.FavoriteColor[Color.Blue], result.FavoriteColor[Color.Blue]); } }
public void TestLoadWithFetchPlanWithLinks() { using (var testContext = new TestDatabaseContext()) using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class("TestClass") .Extends("V") .Run(); ODocument document = new ODocument() .SetField("foo", "foo string value") .SetField("bar", 12345); ODocument insertedDocument = database .Insert(document) .Into("TestClass") .Run(); for (int i = 0; i < 2; i++) { ODocument document2 = new ODocument() .SetField("foo", "bar string value") .SetField("bar", 23456); ODocument insertedDocument2 = database .Insert(document2) .Into("TestClass") .Run(); database.Create.Edge("E").From(insertedDocument).To(insertedDocument2).Run(); } var loaded = database.Load.ORID(insertedDocument.ORID).FetchPlan("*:1").Run(); Assert.Equal("TestClass", loaded.OClassName); Assert.Equal(document.GetField<string>("foo"), loaded.GetField<string>("foo")); Assert.Equal(document.GetField<int>("bar"), loaded.GetField<int>("bar")); Assert.Equal(insertedDocument.ORID, loaded.ORID); } }
public void ShouldUpdateRemoveFieldQuery() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", "foo string value1") .Set("bar", 11111) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", "foo string value2") .Set("bar", 12345) .Run(); int documentsUpdated = database .Update(document2) .Remove("bar") .Run(); Assert.AreEqual(documentsUpdated, 1); List<ODocument> documents = database .Select() .From("TestClass") .Where("foo").Equals("foo string value2") .ToList(); Assert.AreEqual(documents.Count, 1); Assert.AreEqual(documents[0].ORID, document2.ORID); Assert.AreEqual(documents[0].OClassName, document2.OClassName); Assert.AreEqual(documents[0].GetField<string>("foo"), document2.GetField<string>("foo")); Assert.IsFalse(documents[0].HasField("bar")); } } }
public void ShouldInsertIntoClusterSet() { 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 insertedDocument = database .Insert() .Into("TestClass") .Cluster("TestCluster") .Set("foo", "foo string value") .Set("bar", 12345) .Run(); Assert.IsTrue(insertedDocument.ORID != null); Assert.AreEqual(insertedDocument.OClassName, "TestClass"); Assert.AreEqual(insertedDocument.GetField<string>("foo"), "foo string value"); Assert.AreEqual(insertedDocument.GetField<int>("bar"), 12345); } } }
public void ShouldUpdateRecordSet() { 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 document1 = database .Insert(document) .Run(); ODocument document2 = database .Insert(document) .Run(); int documentsUpdated = database .Update(document2.ORID) .Set("bar", 54321) .Set("baz", "new baz value") .Run(); Assert.AreEqual(documentsUpdated, 1); List<ODocument> documents = database .Select() .From("TestClass") .Where("bar").Equals(54321) .ToList(); Assert.AreEqual(documents.Count, 1); Assert.AreEqual(documents[0].ORID, document2.ORID); Assert.AreEqual(documents[0].OClassName, document2.OClassName); Assert.AreEqual(documents[0].GetField<string>("foo"), document2.GetField<string>("foo")); Assert.AreEqual(documents[0].GetField<int>("bar"), 54321); Assert.AreEqual(documents[0].GetField<string>("baz"), "new baz value"); } } }
public void ShouldUpdateRemoveCollectionItem() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class("TestClass") .Run(); ODocument document1 = database .Insert() .Into("TestClass") .Set("foo", new List<string>() { "foo1", "foo2" }) .Set("bar", 11111) .Run(); ODocument document2 = database .Insert() .Into("TestClass") .Set("foo", new List<string>() { "foo1", "foo2" }) .Set("bar", 12345) .Run(); int documentsUpdated = database .Update(document2) .Remove("foo", "foo2") .Run(); Assert.AreEqual(documentsUpdated, 1); List<ODocument> documents = database .Select() .From("TestClass") .Where("bar").Equals(12345) .ToList(); Assert.AreEqual(documents.Count, 1); Assert.AreEqual(documents[0].ORID, document2.ORID); Assert.AreEqual(documents[0].OClassName, document2.OClassName); List<string> foos = new List<string>() { "foo1" }; Assert.AreEqual(documents[0].GetField<List<string>>("foo").Count, foos.Count); Assert.AreEqual(documents[0].GetField<List<string>>("foo")[0], foos[0]); Assert.AreEqual(documents[0].GetField<int>("bar"), document2.GetField<int>("bar")); } } }
public void ShouldInsertClassWithEmbededList() { using (TestDatabaseContext testContext = new TestDatabaseContext()) using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { var employeeListTypeClassName = "EmployeeListType"; var clusterid = db.Create.Class(employeeListTypeClassName).Run(); var employee = new EmployeeListType(); employee.Id = Guid.NewGuid(); employee.Name = new List<string>(); employee.Name.Add("Andrew"); employee.Name.Add("Jack"); employee.Age = new List<int>(); employee.Age.Add(1); employee.Age.Add(2); employee.BirthDate = new List<DateTime>(); employee.BirthDate.Add(DateTime.Now); employee.BirthDate.Add(DateTime.Now.AddDays(-3)); employee.Childs = new List<EmployeeCommonType>(); employee.Childs.Add(new EmployeeCommonType() { Id = Guid.NewGuid() }); employee.Childs.Add(new EmployeeCommonType() { Id = Guid.NewGuid() }); employee.FavoriteColor = new List<Color>(); employee.FavoriteColor.Add(Color.Red); employee.FavoriteColor.Add(Color.Blue); employee.Height = new List<short>(); employee.Height.Add(323); employee.Height.Add(333); employee.Ids = new List<Guid>(); employee.Ids.Add(Guid.NewGuid()); employee.Ids.Add(Guid.NewGuid()); employee.IsMarried = new List<bool>(); employee.IsMarried.Add(true); employee.IsMarried.Add(false); employee.Salary = new List<decimal>(); employee.Salary.Add((decimal)1234567890.123456789); employee.Salary.Add((decimal)1234567890.123456799); employee.Tall = new List<long>(); employee.Tall.Add(3233); employee.Tall.Add(3234); employee.YearlyIncome = new List<double>(); employee.YearlyIncome.Add(3233); employee.YearlyIncome.Add(1234); var document = db.Insert<EmployeeListType>(employee).Run(); var result = db.Query<EmployeeListType>("SELECT * FROM " + employeeListTypeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault(); Assert.Equal(employee.Id, result.Id); Assert.Equal(employee.Ids[0], result.Ids[0]); Assert.Equal(employee.Ids[1], result.Ids[1]); Assert.Equal(employee.Name[0], result.Name[0]); Assert.Equal(employee.Name[1], result.Name[1]); Assert.Equal(employee.Age[0], result.Age[0]); Assert.Equal(employee.Age[1], result.Age[1]); Assert.Equal(employee.Age[0], result.Age[0]); Assert.Equal(employee.Salary[0], result.Salary[0]); Assert.Equal(employee.Salary[1], result.Salary[1]); Assert.Equal(employee.IsMarried[0], result.IsMarried[0]); Assert.Equal(employee.IsMarried[1], result.IsMarried[1]); // Error happen here. Assert.Equal(employee.Childs[0].Id, result.Childs[0].Id); Assert.Equal(employee.Childs[1].Id, result.Childs[1].Id); Assert.Equal(employee.BirthDate[0].ToLongDateString(), result.BirthDate[0].ToLongDateString()); Assert.Equal(employee.BirthDate[1].ToLongDateString(), result.BirthDate[1].ToLongDateString()); Assert.Equal(employee.YearlyIncome[0], result.YearlyIncome[0]); Assert.Equal(employee.YearlyIncome[1], result.YearlyIncome[1]); Assert.Equal(employee.FavoriteColor[0], result.FavoriteColor[0]); Assert.Equal(employee.FavoriteColor[1], result.FavoriteColor[1]); Assert.Equal(employee.Height[0], result.Height[0]); Assert.Equal(employee.Height[1], result.Height[1]); Assert.Equal(employee.Tall[0], result.Tall[0]); Assert.Equal(employee.Tall[1], result.Tall[1]); } }
public void GIVEN___EmployeeArrayType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read() { using (TestDatabaseContext testContext = new TestDatabaseContext()) using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { var employeeClassName = "EmployeeArrayType"; var clusterid = db.Create.Class(employeeClassName).Run(); var employee = new EmployeeArrayType(); employee.Id = Guid.NewGuid(); employee.Name = new string[2]; employee.Name[0] = "Andrew"; employee.Name[1] = ("Jack"); employee.Age = new int[2]; employee.Age[0] = (1); employee.Age[1] = (2); employee.BirthDate = new DateTime[2]; employee.BirthDate[0] = (DateTime.Now); employee.BirthDate[1] = (DateTime.Now.AddDays(-3)); employee.Childs = new EmployeeCommonType[2]; employee.Childs[0] = (new EmployeeCommonType() { Id = Guid.NewGuid() }); employee.Childs[1] = (new EmployeeCommonType() { Id = Guid.NewGuid() }); employee.FavoriteColor = new Color[2]; employee.FavoriteColor[0] = (Color.Red); employee.FavoriteColor[1] = (Color.Blue); employee.Height = new short[2]; employee.Height[0] = (323); employee.Height[1] = (333); employee.Ids = new Guid[2]; employee.Ids[0] = (Guid.NewGuid()); employee.Ids[1] = (Guid.NewGuid()); employee.IsMarried = new bool[2]; employee.IsMarried[0] = (true); employee.IsMarried[1] = (false); employee.Salary = new decimal[2]; employee.Salary[0] = ((decimal)1234567890.123456789); employee.Salary[1] = ((decimal)1234567890.123456799); employee.Tall = new long[2]; employee.Tall[0] = (3233); employee.Tall[1] = (3234); employee.YearlyIncome = new double[2]; employee.YearlyIncome[0] = (3233); employee.YearlyIncome[1] = (1234); var document = db.Insert<EmployeeArrayType>(employee).Run(); var result = db.Query<EmployeeArrayType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault(); Assert.AreEqual(employee.Id, result.Id); Assert.AreEqual(employee.Ids[0], result.Ids[0]); Assert.AreEqual(employee.Ids[1], result.Ids[1]); Assert.AreEqual(employee.Name[0], result.Name[0]); Assert.AreEqual(employee.Name[1], result.Name[1]); Assert.AreEqual(employee.Age[0], result.Age[0]); Assert.AreEqual(employee.Age[1], result.Age[1]); Assert.AreEqual(employee.Age[0], result.Age[0]); Assert.AreEqual(employee.Salary[0], result.Salary[0]); Assert.AreEqual(employee.Salary[1], result.Salary[1]); Assert.AreEqual(employee.IsMarried[0], result.IsMarried[0]); Assert.AreEqual(employee.IsMarried[1], result.IsMarried[1]); Assert.AreEqual(employee.Childs[0].Id, result.Childs[0].Id); Assert.AreEqual(employee.Childs[1].Id, result.Childs[1].Id); Assert.AreEqual(employee.BirthDate[0].ToLongDateString(), result.BirthDate[0].ToLongDateString()); Assert.AreEqual(employee.BirthDate[1].ToLongDateString(), result.BirthDate[1].ToLongDateString()); Assert.AreEqual(employee.YearlyIncome[0], result.YearlyIncome[0]); Assert.AreEqual(employee.YearlyIncome[1], result.YearlyIncome[1]); Assert.AreEqual(employee.FavoriteColor[0], result.FavoriteColor[0]); Assert.AreEqual(employee.FavoriteColor[1], result.FavoriteColor[1]); Assert.AreEqual(employee.Height[0], result.Height[0]); Assert.AreEqual(employee.Height[1], result.Height[1]); Assert.AreEqual(employee.Tall[0], result.Tall[0]); Assert.AreEqual(employee.Tall[1], result.Tall[1]); } }
public void ShouldSelectToObjectList() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias)) { // prerequisites database .Create.Class<TestProfileClass>() .Run(); TestProfileClass document1 = database .Insert() .Into<TestProfileClass>() .Set("Name", "Johny") .Set("Surname", "Bravo") .Run<TestProfileClass>(); TestProfileClass document2 = database .Insert() .Into<TestProfileClass>() .Set("Name", "Johny") .Set("Surname", "Bravo") .Run<TestProfileClass>(); List<TestProfileClass> documents = database .Select() .From<TestProfileClass>() .ToList<TestProfileClass>(); Assert.AreEqual(documents.Count, 2); Assert.AreEqual(documents[0].ORID, document1.ORID); Assert.AreEqual(documents[0].OClassName, document1.OClassName); Assert.AreEqual(documents[0].Name, document1.Name); Assert.AreEqual(documents[0].Surname, document1.Surname); Assert.AreEqual(documents[1].ORID, document2.ORID); Assert.AreEqual(documents[1].OClassName, document2.OClassName); Assert.AreEqual(documents[1].Name, document2.Name); Assert.AreEqual(documents[1].Surname, document2.Surname); } } }