예제 #1
0
        public void TestIdentityMapperMappingViaExpressionForBaseProperty()
        {
            // Derived 1

            // Setup
            IdentityMapper.Add <IdentityMapperTestDerivedClass1>(e => e.ColumnId);

            // Act
            var actual   = IdentityMapper.Get <IdentityMapperTestDerivedClass1>();
            var expected = "ColumnId";

            // Assert
            Assert.IsTrue(actual?.IsIdentity() == true);
            Assert.AreEqual(expected, actual?.GetMappedName());

            // Derived 2

            // Setup
            IdentityMapper.Add <IdentityMapperTestDerivedClass2>(e => e.ColumnId);

            // Act
            actual   = IdentityMapper.Get <IdentityMapperTestDerivedClass2>();
            expected = "ColumnId";

            // Assert
            Assert.IsTrue(actual?.IsIdentity() == true);
            Assert.AreEqual(expected, actual?.GetMappedName());
        }
예제 #2
0
        public void TestClassMapIdentityMappingOverride()
        {
            // Setup
            IdentityMapper.Add <ClassMapperTestClass>(e => e.RowId, true);

            // Act
            var actual   = IdentityCache.Get <ClassMapperTestClass>();
            var expected = "RowId";

            // Assert
            Assert.AreEqual(expected, actual.GetMappedName());
        }
예제 #3
0
        public void TestIdentityMapperMappingViaExpression()
        {
            // Setup
            IdentityMapper.Add <IdentityMapperTestClass>(e => e.ColumnInt);

            // Act
            var actual   = IdentityMapper.Get <IdentityMapperTestClass>();
            var expected = "ColumnInt";

            // Assert
            Assert.IsTrue(actual?.IsIdentity() == true);
            Assert.AreEqual(expected, actual?.GetMappedName());
        }
예제 #4
0
        public void TestIdentityMapperMappingViaFieldOverride()
        {
            // Setup
            IdentityMapper.Add <IdentityMapperTestClass>(new Field("ColumnInt"));
            IdentityMapper.Add <IdentityMapperTestClass>(new Field("ColumnString"), true);

            // Act
            var actual   = IdentityMapper.Get <IdentityMapperTestClass>();
            var expected = "ColumnString";

            // Assert
            Assert.IsTrue(actual?.IsIdentity() == true);
            Assert.AreEqual(expected, actual?.GetMappedName());
        }
예제 #5
0
        public void TestIdentityMapperMappingViaFieldWithMapAttribute()
        {
            // Setup
            IdentityMapper.Add <IdentityMapperTestWithAttributeClass>(new Field("ColumnInt"));

            // Act
            var actual   = IdentityMapper.Get <IdentityMapperTestWithAttributeClass>();
            var expected = "ColumnInt";

            // Assert
            Assert.IsTrue(actual?.IsIdentity() == true);
            Assert.AreEqual(expected, actual?.GetMappedName());

            // Act
            actual   = IdentityCache.Get <IdentityMapperTestWithAttributeClass>();
            expected = "ColumnString";

            // Assert
            Assert.IsTrue(actual?.IsIdentity() == true);
            Assert.AreEqual(expected, actual?.GetMappedName());
        }
예제 #6
0
 public void ThrowExceptionOnClassMapIdentityMappingThatIsAlreadyExisting()
 {
     // Setup
     IdentityMapper.Add <ClassMapperTestClass>(e => e.RowId);
 }
예제 #7
0
 public void ThrowExceptionOnIdentityMapperViaFieldThatIsIsMissing()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(new Field("Whatever"));
 }
예제 #8
0
 public void ThrowExceptionOnIdentityMapperViaPropertyNameThatIsMissing()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>("Whatever");
 }
예제 #9
0
 public void ThrowExceptionOnIdentityMapperViaFieldThatIsEmptySpaces()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(field: new Field("  "));
 }
예제 #10
0
 public void ThrowExceptionOnIdentityMapperViaPropertyNameThatIsEmptySpaces()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(propertyName: "  ");
 }
예제 #11
0
 public void ThrowExceptionOnIdentityMapperViaExpressionThatIsNull()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(expression: null);
 }
예제 #12
0
 public void ThrowExceptionOnIdentityMapperViaFieldThatIsNull()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(field: null);
 }
예제 #13
0
 public void ThrowExceptionOnIdentityMapperViaPropertyNameThatIsNull()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(propertyName: null);
 }
예제 #14
0
 public void ThrowExceptionOnIdentityMapperViaExpressionThatIsAlreadyExisting()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(e => e.ColumnInt);
     IdentityMapper.Add <IdentityMapperTestClass>(e => e.ColumnString);
 }
예제 #15
0
 public void ThrowExceptionOnIdentityMapperViaFieldThatIsAlreadyExisting()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>(new Field("ColumnInt"));
     IdentityMapper.Add <IdentityMapperTestClass>(new Field("ColumnString"));
 }
예제 #16
0
 public void ThrowExceptionOnIdentityMapperViaPropertyNameThatIsAlreadyExisting()
 {
     // Setup
     IdentityMapper.Add <IdentityMapperTestClass>("ColumnInt");
     IdentityMapper.Add <IdentityMapperTestClass>("ColumnString");
 }