public void GetSequence_finds_sequence_by_name()
        {
            var database = new DatabaseModel();
            var sequence0 = new Sequence("dbo.MySequence0");
            var sequence1 = new Sequence("dbo.MySequence1");

            database.AddSequence(sequence0);
            database.AddSequence(sequence1);

            Assert.Same(sequence0, database.GetSequence("dbo.MySequence0"));
            Assert.Same(sequence1, database.GetSequence("dbo.MySequence1"));
        }
        public void Sequences_gets_read_only_list_of_sequences()
        {
            var database = new DatabaseModel();
            var sequence0 = new Sequence("dbo.MySequence0");
            var sequence1 = new Sequence("dbo.MySequence1");

            database.AddSequence(sequence0);
            database.AddSequence(sequence1);

            Assert.IsAssignableFrom<IReadOnlyList<Sequence>>(database.Sequences);
            Assert.Equal(2, database.Sequences.Count);
            Assert.Same(sequence0, database.Sequences[0]);
            Assert.Same(sequence1, database.Sequences[1]);
        }
        public void RemoveSequence_removes_specified_sequence()
        {
            var database = new DatabaseModel();
            var sequence0 = new Sequence("dbo.MySequence0");
            var sequence1 = new Sequence("dbo.MySequence1");

            database.AddSequence(sequence0);
            database.AddSequence(sequence1);

            Assert.Equal(2, database.Sequences.Count);

            database.RemoveSequence("dbo.MySequence1");

            Assert.Equal(1, database.Sequences.Count);
            Assert.Same(sequence0, database.Sequences[0]);
        }
        public void AddSequence_adds_specified_sequence()
        {
            var database = new DatabaseModel();

            Assert.Equal(0, database.Sequences.Count);

            var sequence = new Sequence("dbo.MySequence");
            database.AddSequence(sequence);

            Assert.Equal(1, database.Sequences.Count);
            Assert.Same(sequence, database.Sequences[0]);
        }
        public void Clone_replicates_tables()
        {            
            var databaseModel = new DatabaseModel();
            var sequence0 = new Sequence("dbo.S0");
            var sequence1 = new Sequence("dbo.S1");
            var table0 = new Table("dbo.T0");
            var table1 = new Table("dbo.T1");

            databaseModel.AddSequence(sequence0);
            databaseModel.AddSequence(sequence1);
            databaseModel.AddTable(table0);
            databaseModel.AddTable(table1);

            var clone = databaseModel.Clone();

            Assert.NotSame(databaseModel, clone);
            Assert.Equal(2, clone.Sequences.Count);
            Assert.NotSame(sequence0, clone.Sequences[0]);
            Assert.NotSame(sequence1, clone.Sequences[1]);
            Assert.Equal("dbo.S0", clone.Sequences[0].Name);
            Assert.Equal("dbo.S1", clone.Sequences[1].Name);
            Assert.Equal(2, clone.Tables.Count);
            Assert.NotSame(table0, clone.Tables[0]);
            Assert.NotSame(table1, clone.Tables[1]);
            Assert.Equal("dbo.T0", clone.Tables[0].Name);
            Assert.Equal("dbo.T1", clone.Tables[1].Name);
        }