예제 #1
0
        public void Clone_gets_column_clones_from_cache()
        {
            var column0 = new Column("Foo", typeof(int));
            var column1 = new Column("Bar", typeof(int));
            var primaryKey = new PrimaryKey("PK", new[] { column0, column1 }, isClustered: false);
            
            var cloneContext = new CloneContext();
            var columnClone0 = column0.Clone(cloneContext);
            var columnClone1 = column1.Clone(cloneContext);
            var clone = primaryKey.Clone(cloneContext);

            Assert.NotSame(primaryKey, clone);
            Assert.Equal(2, clone.Columns.Count);
            Assert.Same(columnClone0, clone.Columns[0]);
            Assert.Same(columnClone1, clone.Columns[1]);
        }
예제 #2
0
        public void Clone_gets_column_clones_from_cache()
        {
            var column0 = new Column("Foo", typeof(int));
            var column1 = new Column("Bar", typeof(int));
            var index = new Index("IX", new[] { column0, column1 }, isUnique: true, isClustered: true);

            var cloneContext = new CloneContext();
            var columnClone0 = column0.Clone(cloneContext);
            var columnClone1 = column1.Clone(cloneContext);
            var clone = index.Clone(cloneContext);

            Assert.NotSame(index, clone);
            Assert.Equal(2, clone.Columns.Count);
            Assert.Same(columnClone0, clone.Columns[0]);
            Assert.Same(columnClone1, clone.Columns[1]);
        }
예제 #3
0
        public void Clone_replicates_instance()
        {
            var cloneContext = new CloneContext();
            var column
                = new Column("Foo", typeof(string))
                {
                    DataType = "T",
                    IsNullable = false,
                    DefaultValue = "V",
                    DefaultSql = "Sql",
                    ValueGenerationStrategy = ValueGenerationOnSave.WhenInsertingAndUpdating,
                    IsTimestamp = true,
                    MaxLength = 4,
                    Precision = 3,
                    Scale = 2,
                    IsFixedLength = true,
                    IsUnicode = true
                };
            var clone = column.Clone(cloneContext);

            Assert.NotSame(column, clone);
            Assert.Equal("Foo", clone.Name);
            Assert.Same(typeof(string), clone.ClrType);
            Assert.Equal("T", clone.DataType);
            Assert.Equal("V", clone.DefaultValue);
            Assert.Equal("Sql", clone.DefaultSql);
            Assert.Equal(ValueGenerationOnSave.WhenInsertingAndUpdating, clone.ValueGenerationStrategy);
            Assert.True(clone.IsTimestamp);
            Assert.Equal(4, clone.MaxLength.Value);
            Assert.Equal(3, clone.Precision.Value);
            Assert.Equal(2, clone.Scale.Value);
            Assert.True(clone.IsFixedLength.Value);
            Assert.True(clone.IsUnicode.Value);
        }
예제 #4
0
        public void Clone_adds_new_clone_to_cache()
        {
            var cloneContext = new CloneContext();
            var column = new Column("Foo", typeof(string));
            var clone = column.Clone(cloneContext);

            Assert.NotSame(column, clone);
            Assert.Same(clone, cloneContext.GetOrAdd(column, () => null));
        }
예제 #5
0
        public void Clone_gets_existing_clone_from_cache()
        {
            var cloneContext = new CloneContext();
            var column = new Column("Foo", typeof(string));
            var clone = new Column("Foo", typeof(string));

            Assert.Same(clone, cloneContext.GetOrAdd(column, () => clone));
            Assert.Same(clone, column.Clone(cloneContext));
        }
예제 #6
0
        public void Clone_gets_column_clones_from_cache()
        {
            var column0 = new Column("C0", typeof(int));
            var column1 = new Column("C1", typeof(int));
            var referencedColumn0 = new Column("RC0", typeof(int));
            var referencedColumn1 = new Column("RC1", typeof(int));
            var foreignKey
                = new ForeignKey(
                    "FK",
                    new[] { column0, column1 },
                    new[] { referencedColumn0, referencedColumn1 },
                    cascadeDelete: true);

            var cloneContext = new CloneContext();
            var columnClone0 = column0.Clone(cloneContext);
            var columnClone1 = column1.Clone(cloneContext);
            var referencedColumnClone0 = referencedColumn0.Clone(cloneContext);
            var referencedColumnClone1 = referencedColumn1.Clone(cloneContext);
            var clone = foreignKey.Clone(cloneContext);

            Assert.NotSame(foreignKey, clone);
            Assert.Equal(2, clone.Columns.Count);
            Assert.Same(columnClone0, clone.Columns[0]);
            Assert.Same(columnClone1, clone.Columns[1]);
            Assert.Equal(2, clone.ReferencedColumns.Count);
            Assert.Same(referencedColumnClone0, clone.ReferencedColumns[0]);
            Assert.Same(referencedColumnClone1, clone.ReferencedColumns[1]);
        }