public virtual void Create_and_clone_UDT_mapping_with_converter() { var mapping = new SqlServerUdtTypeMapping( typeof(object), "storeType", RelationalTypeMapping.StoreTypeModifierKind.None, "udtType", new FakeValueConverter(), new FakeValueComparer(), new FakeValueComparer(), DbType.VarNumeric, false, 33, true); var clone = (SqlServerUdtTypeMapping)mapping.Clone("<clone>", 66); Assert.NotSame(mapping, clone); Assert.Same(mapping.GetType(), clone.GetType()); Assert.Equal("storeType", mapping.StoreType); Assert.Equal("<clone>", clone.StoreType); Assert.Equal("udtType", mapping.UdtTypeName); Assert.Equal("udtType", clone.UdtTypeName); Assert.Equal(DbType.VarNumeric, clone.DbType); Assert.Equal(33, mapping.Size); Assert.Equal(66, clone.Size); Assert.False(mapping.IsUnicode); Assert.False(clone.IsUnicode); Assert.NotNull(mapping.Converter); Assert.Same(mapping.Converter, clone.Converter); Assert.Same(mapping.Comparer, clone.Comparer); Assert.Same(mapping.KeyComparer, clone.KeyComparer); Assert.Same(typeof(object), clone.ClrType); Assert.True(mapping.IsFixedLength); Assert.True(clone.IsFixedLength); var newConverter = new FakeValueConverter(); clone = (SqlServerUdtTypeMapping)mapping.Clone(newConverter); Assert.NotSame(mapping, clone); Assert.Same(mapping.GetType(), clone.GetType()); Assert.Equal("storeType", mapping.StoreType); Assert.Equal("storeType", clone.StoreType); Assert.Equal("udtType", mapping.UdtTypeName); Assert.Equal("udtType", clone.UdtTypeName); Assert.Equal(DbType.VarNumeric, clone.DbType); Assert.Equal(33, mapping.Size); Assert.Equal(33, clone.Size); Assert.False(mapping.IsUnicode); Assert.False(clone.IsUnicode); Assert.NotSame(mapping.Converter, clone.Converter); Assert.Same(mapping.Comparer, clone.Comparer); Assert.Same(mapping.KeyComparer, clone.KeyComparer); Assert.Same(typeof(object), clone.ClrType); Assert.True(mapping.IsFixedLength); Assert.True(clone.IsFixedLength); }
public virtual void Create_and_clone_UDT_mapping_with_converter() { Func <object, Expression> literalGenerator = Expression.Constant; var mapping = new SqlServerUdtTypeMapping( typeof(object), "storeType", literalGenerator, StoreTypePostfix.None, "udtType", new FakeValueConverter(), new FakeValueComparer(), new FakeValueComparer(), DbType.VarNumeric, false, 33, true); var clone = (SqlServerUdtTypeMapping)mapping.Clone("<clone>", 66); Assert.NotSame(mapping, clone); Assert.Same(mapping.GetType(), clone.GetType()); Assert.Equal("storeType", mapping.StoreType); Assert.Equal("<clone>", clone.StoreType); Assert.Equal("udtType", mapping.UdtTypeName); Assert.Equal("udtType", clone.UdtTypeName); Assert.Equal(DbType.VarNumeric, clone.DbType); Assert.Equal(33, mapping.Size); Assert.Equal(66, clone.Size); Assert.False(mapping.IsUnicode); Assert.False(clone.IsUnicode); Assert.NotNull(mapping.Converter); Assert.Same(mapping.Converter, clone.Converter); Assert.Same(mapping.Comparer, clone.Comparer); Assert.Same(mapping.KeyComparer, clone.KeyComparer); Assert.Same(typeof(object), clone.ClrType); Assert.True(mapping.IsFixedLength); Assert.True(clone.IsFixedLength); Assert.Same(literalGenerator, clone.LiteralGenerator); var newConverter = new FakeValueConverter(); clone = (SqlServerUdtTypeMapping)mapping.Clone(newConverter); Assert.NotSame(mapping, clone); Assert.Same(mapping.GetType(), clone.GetType()); Assert.Equal("storeType", mapping.StoreType); Assert.Equal("storeType", clone.StoreType); Assert.Equal("udtType", mapping.UdtTypeName); Assert.Equal("udtType", clone.UdtTypeName); Assert.Equal(DbType.VarNumeric, clone.DbType); Assert.Equal(33, mapping.Size); Assert.Equal(33, clone.Size); Assert.False(mapping.IsUnicode); Assert.False(clone.IsUnicode); Assert.NotSame(mapping.Converter, clone.Converter); Assert.Same(mapping.Comparer, clone.Comparer); Assert.Same(mapping.KeyComparer, clone.KeyComparer); Assert.Same(typeof(object), clone.ClrType); Assert.True(mapping.IsFixedLength); Assert.True(clone.IsFixedLength); Assert.Same(literalGenerator, clone.LiteralGenerator); }