public void ForeignKeyExceptionIsRecognized1() { // --- Arrange var parent = new ParentRecord { Name = "Parent", }; var child = new ChildRecord { Name = "Child1", Value = 1, ParentId = -1 }; // --- Act ForeignKeyViolationException exCaught = null; try { using (var ctx = DataAccessFactory.CreateContext <ITestDataOperations>()) { ctx.InsertParent(parent, false); ctx.InsertChild(child); } } catch (ForeignKeyViolationException ex) { exCaught = ex; } // --- Assert // ReSharper disable once PossibleNullReferenceException exCaught.KeyName.ShouldEqual("FK_Child_ToParent"); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException ForeignKeyViolation(int surr1, int surr2) { Obj arg1 = source.store.SurrToValue(surr1); Obj arg2 = source.store.SurrToValue(surr2); return(ForeignKeyViolationException.SymBinarySymTernary(source.relvarName, target.relvarName, arg1, arg2)); }
private ForeignKeyViolationException ForeignKeyViolation(int surr, int otherSurr) { Obj arg = source.store.SurrToValue(surr); Obj otherArg = source.store.SurrToValue(otherSurr); return(ForeignKeyViolationException.UnarySymBinary(source.relvarName, target.relvarName, arg, otherArg)); }
private ForeignKeyViolationException ForeignKeyViolation(int keySurr) { Obj key = source.store.SurrToValue(keySurr); Obj[] fromTuple = new Obj[] { key, new FloatObj(source.Lookup(keySurr)) }; return(ForeignKeyViolationException.BinaryUnary(source.relvarName, 1, target.relvarName, fromTuple, key)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException InsertionForeignKeyViolation(int surr1, int surr2) { Obj obj1 = source.store1.SurrToValue(surr1); Obj obj2 = source.store2.SurrToValue(surr2); return(ForeignKeyViolationException.BinaryTernary(source.relvarName, target.relvarName, obj1, obj2)); }
private ForeignKeyViolationException ForeignKeyViolation(int delSurr) { int otherSurr = source.table.Restrict(delSurr)[0]; Obj arg1 = source.store.SurrToValue(delSurr); Obj[] tuple1 = new Obj[] { arg1, source.store.SurrToValue(otherSurr) }; return(ForeignKeyViolationException.SymBinaryUnary(source.relvarName, target.relvarName, tuple1, arg1)); }
private ForeignKeyViolationException DeletionForeignKeyViolation(int surr1) { int surr2 = source.table.Restrict1(surr1)[0]; //## BAD: VERY INEFFICIENT Obj obj1 = source.store1.SurrToValue(surr1); Obj[] tuple = new Obj[] { obj1, source.store2.SurrToValue(surr2) }; return(ForeignKeyViolationException.BinaryUnary(source.relvarName, 1, target.relvarName, tuple, obj1)); }
private ForeignKeyViolationException ForeignKeyViolation(int delSurr12, int otherSurr12, int surr3) { Obj delArg12 = source.store.SurrToValue(delSurr12); Obj otherArg12 = source.store.SurrToValue(otherSurr12); Obj arg3 = target.store3.SurrToValue(surr3); return(ForeignKeyViolationException.UnarySym12Ternary(source.relvarName, target.relvarName, delArg12, otherArg12, arg3)); }
private ForeignKeyViolationException DeletionForeignKeyViolationException(int surr1, int surr2) { Obj obj1 = source.store.SurrToValue(surr1); Obj obj2 = target.store2.SurrToValue(surr2); Obj[] tuple = new Obj[] { obj1, obj2 }; return(ForeignKeyViolationException.UnaryBinary(source.relvarName, 1, target.relvarName, tuple)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException InsertionForeignKeyViolation(int surr1, int surr2, int surr3) { Obj obj1 = source.store1.SurrToValue(surr1); Obj obj2 = source.store2.SurrToValue(surr2); Obj obj3 = source.store3.SurrToValue(surr3); Obj[] tuple = new Obj[] { obj1, obj2, obj3 }; return(ForeignKeyViolationException.TernaryBinary(source.relvarName, target.relvarName, tuple)); }
private ForeignKeyViolationException ForeignKeyViolation(int surr1, int surr2, int surr3) { Obj arg1 = target.store1.SurrToValue(surr1); Obj arg2 = target.store2.SurrToValue(surr2); Obj arg3 = target.store3.SurrToValue(surr3); Obj[] tuple = new Obj[] { arg1, arg2, arg3 }; return(ForeignKeyViolationException.UnaryTernary(source.relvarName, 3, target.relvarName, tuple)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException ForeignKeyViolation(int arg1Surr, int arg2Surr, int arg3Surr) { Obj[] tuple = new Obj[] { source.store12.SurrToValue(arg1Surr), source.store12.SurrToValue(arg2Surr), source.store3.SurrToValue(arg3Surr) }; return(ForeignKeyViolationException.SymTernary12Unary(source.relvarName, target.relvarName, tuple)); }
private ForeignKeyViolationException DeletionForeignKeyViolation(int surr1, int surr2) { Obj obj1 = source.store1.SurrToValue(surr1); Obj obj2 = source.store2.SurrToValue(surr2); Obj obj3 = source.store3.SurrToValue(source.LookupAny12(surr1, surr2)); Obj[] fromTuple = new Obj[] { obj1, obj2, obj3 }; Obj[] toTuple = new Obj[] { obj1, obj2 }; return(ForeignKeyViolationException.TernaryBinary(source.relvarName, target.relvarName, fromTuple, toTuple)); }
private ForeignKeyViolationException ForeignKeyViolation(int delSurr) { TernaryTable.Iter1 it = source.table.GetIter1(delSurr); Obj arg1 = source.store1.SurrToValue(delSurr); Obj arg2 = source.store2.SurrToValue(it.Get1()); Obj arg3 = source.store3.SurrToValue(it.Get2()); Obj[] tuple = new Obj[] { arg1, arg2, arg3 }; return(ForeignKeyViolationException.TernaryUnary(source.relvarName, 1, target.relvarName, tuple, arg1)); }
private ForeignKeyViolationException ForeignKeyViolation(int arg12Surr) { Sym12TernaryTable.Iter it = source.table.getIter_1_2(arg12Surr); Obj arg1 = source.store12.SurrToValue(arg12Surr); Obj arg2 = source.store12.SurrToValue(it.Get1()); Obj arg3 = source.store3.SurrToValue(it.Get2()); Obj[] tuple = new Obj[] { arg1, arg2, arg3 }; return(ForeignKeyViolationException.SymTernary12Unary(source.relvarName, target.relvarName, tuple, arg1)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException ForeignKeyViolation(int surr) { Obj arg = source.store.SurrToValue(surr); return(ForeignKeyViolationException.UnaryTernary(source.relvarName, 3, target.relvarName, arg)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException ForeignKeyViolation(int surr) { return(ForeignKeyViolationException.UnaryUnary(source.relvarName, target.relvarName, source.store.SurrToValue(surr))); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException ForeignKeyViolation(int keySurr, double value) { Obj[] tuple = new Obj[] { source.store.SurrToValue(keySurr), new FloatObj(value) }; return(ForeignKeyViolationException.BinaryUnary(source.relvarName, 1, target.relvarName, tuple)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException InsertionForeignKeyViolation(int surr1, int surr2) { Obj[] tuple = new Obj[] { source.store1.SurrToValue(surr1), source.store2.SurrToValue(surr2) }; return(ForeignKeyViolationException.BinaryUnary(source.relvarName, 1, target.relvarName, tuple)); }
////////////////////////////////////////////////////////////////////////////// private ForeignKeyViolationException InsertionForeignKeyViolationException(int surr) { Obj obj = source.store.SurrToValue(surr); return(ForeignKeyViolationException.UnaryBinary(source.relvarName, 1, target.relvarName, obj)); }