static Key selector(TestTable1 t) { const string testString = "test"; var strLength = testString.Length; Debug.Assert(strLength > 0); return(t.PK_TARGET); }
public static void KeySelector_WithSelectorUniqueKeyAndPropertyInfoNotSet_ThrowsInvalidOperationException() { var testColumn = Mock.Of <IModelledColumn>(); var foreignKey = new Key.Foreign <TestTable1>(t => t.UK_TARGET, testColumn); var instance = new TestTable1(); Assert.That(() => foreignKey.KeySelector.Invoke(instance), Throws.InvalidOperationException); }
public static void KeySelector_WithSimpleFunctionToUniqueKey_ReturnsCorrectKey() { var testColumn = Mock.Of <IModelledColumn>(); var foreignKey = new Key.Foreign <TestTable1>(t => t.UK_TARGET, testColumn) { Property = typeof(TestTable1) .GetProperties() .Single(p => p.Name == nameof(TestTable1.FK_UK_SOURCE)) }; var instance = new TestTable1(); var targetKey = foreignKey.KeySelector.Invoke(instance); Assert.That(targetKey.KeyType, Is.EqualTo(DatabaseKeyType.Unique)); }