public void ForeignKeyConstraintWhileInsertTest() { var ownerObj = new TestObjWithOne2Many { Id = 1, Text = "Test1" }; var testObjects = Enumerable.Range(1, 10) .Select(i => new TestDependentObj1 { Id = i, OwnerId = ownerObj.Id, Text = "Test" + i }).ToList(); testObjects.Add(new TestDependentObj1 { Id = 11, OwnerId = 99 }); ownerObj.ObjList = testObjects; string exception = string.Empty; try{ _db.Insert(ownerObj); } catch (SQLiteException ex) { exception = ex.Message; } Assert.AreNotEqual(string.Empty, exception); Assert.AreEqual("Constraint", exception); }
public void InsertOrReplaceWithOwnerIdAutogetting() { var ownerObj = new TestObjWithOne2Many { Text = "Test1" }; var testObjects = Enumerable.Range(1, 10) .Select(i => new TestDependentObj1 { Text = "Test" + i }).ToList(); ownerObj.ObjList = testObjects; _db.InsertOrReplace(ownerObj); var tmpObject = _db.Table <TestObjWithOne2Many>().First(); foreach (var o in tmpObject.ObjList) { o.Text += o.Id; } tmpObject.Text = "Test2"; _db.InsertOrReplace(tmpObject); var resultObjs = _db.Table <TestObjWithOne2Many>().ToList(); Assert.AreEqual(1, resultObjs.Count); Assert.AreEqual(tmpObject.ObjList[0].Text, resultObjs[0].ObjList[0].Text); Assert.AreNotEqual(ownerObj.ObjList[0].Text, resultObjs[0].ObjList[0].Text); }
public void InsertObjWithOwnerIdAutogetting() { var ownerObj = new TestObjWithOne2Many(); var testObjects = Enumerable.Range(1, 10) .Select(i => new TestDependentObj1 { Text = "Test" + i }).ToList(); ownerObj.ObjList = testObjects; _db.Insert(ownerObj); var resultObj = _db.Table <TestObjWithOne2Many>().First(); Assert.AreNotEqual(null, resultObj); Assert.AreEqual(10, resultObj.ObjList.Count); Assert.AreEqual("Test1", resultObj.ObjList.First(x => x.Id == 1).Text); }
public void ForeignKeyConstraintWhileInsertTest() { var ownerObj = new TestObjWithOne2Many {Id = 1, Text = "Test1"}; var testObjects = Enumerable.Range(1,10) .Select(i => new TestDependentObj1 {Id = i,OwnerId = ownerObj.Id, Text = "Test"+i}).ToList(); testObjects.Add(new TestDependentObj1{Id = 11,OwnerId = 99}); ownerObj.ObjList = testObjects; string exception = string.Empty; try{ _db.Insert(ownerObj); } catch(SQLiteException ex){ exception = ex.Message; } Assert.AreNotEqual(string.Empty,exception); Assert.AreEqual("Constraint", exception); }
public void InsertOrReplaceWithOwnerIdAutogetting() { var ownerObj = new TestObjWithOne2Many {Text = "Test1"}; var testObjects = Enumerable.Range(1,10) .Select(i => new TestDependentObj1 {Text = "Test"+i}).ToList(); ownerObj.ObjList = testObjects; _db.InsertOrReplace(ownerObj); var tmpObject = _db.Table<TestObjWithOne2Many>().First(); foreach(var o in tmpObject.ObjList) { o.Text += o.Id; } tmpObject.Text = "Test2"; _db.InsertOrReplace(tmpObject); var resultObjs = _db.Table<TestObjWithOne2Many>().ToList(); Assert.AreEqual(1, resultObjs.Count); Assert.AreEqual(tmpObject.ObjList[0].Text, resultObjs[0].ObjList[0].Text); Assert.AreNotEqual(ownerObj.ObjList[0].Text, resultObjs[0].ObjList[0].Text); }
public void InsertObjWithOwnerIdAutogetting() { var ownerObj = new TestObjWithOne2Many (); var testObjects = Enumerable.Range(1,10) .Select(i => new TestDependentObj1 {Text = "Test"+i}).ToList(); ownerObj.ObjList = testObjects; _db.Insert(ownerObj); var resultObj = _db.Table<TestObjWithOne2Many>().First(); Assert.AreNotEqual(null,resultObj); Assert.AreEqual(10,resultObj.ObjList.Count); Assert.AreEqual("Test1",resultObj.ObjList.First(x => x.Id == 1).Text); }