Beispiel #1
0
            static Key selector(TestTable1 t)
            {
                const string testString = "test";
                var          strLength  = testString.Length;

                Debug.Assert(strLength > 0);
                return(t.PK_TARGET);
            }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }