コード例 #1
0
        public void GetCreateScript_GetDropScript_ValidConnectionString()
        {
            var statement1       = new ScriptStatement("Test1");
            var statement2       = new ScriptStatement("Test2");
            var fakeCreateResult = new ScriptElementCollection();

            fakeCreateResult.AddElement(statement1);
            fakeCreateResult.AddElement(statement2);
            var fakeDropResult = new ScriptElementCollection();

            fakeDropResult.AddElement(statement2);
            fakeDropResult.AddElement(statement1);

            _innerScriptBuilderMock.Expect(mock => mock.GetCreateScript()).Return(fakeCreateResult);
            _innerScriptBuilderMock.Expect(mock => mock.GetDropScript()).Return(fakeDropResult);

            var createScriptResult = _builder.GetCreateScript();
            var dropScriptResult   = _builder.GetDropScript();

            Assert.That(((ScriptElementCollection)createScriptResult).Elements.Count, Is.EqualTo(2));
            Assert.That(((ScriptStatement)((ScriptElementCollection)createScriptResult).Elements[0]).Statement, Is.EqualTo("USE MyDataBase"));
            Assert.That(((ScriptElementCollection)createScriptResult).Elements[1], Is.SameAs(fakeCreateResult));
            Assert.That(((ScriptElementCollection)dropScriptResult).Elements.Count, Is.EqualTo(2));
            Assert.That(((ScriptStatement)((ScriptElementCollection)dropScriptResult).Elements[0]).Statement, Is.EqualTo("USE MyDataBase"));
            Assert.That(((ScriptElementCollection)dropScriptResult).Elements[1], Is.SameAs(fakeDropResult));
        }
        public IScriptElement GetDropScript()
        {
            var dropScriptElements = new ScriptElementCollection();

            dropScriptElements.AddElement(new ScriptStatement("USE " + GetDatabaseName()));
            dropScriptElements.AddElement(_innerScriptBuilder.GetDropScript());
            return(dropScriptElements);
        }
コード例 #3
0
        public void SetUp()
        {
            _elementCollection = new ScriptElementCollection();

            _elementMock1 = MockRepository.GenerateStrictMock <IScriptElement> ();
            _elementMock2 = MockRepository.GenerateStrictMock <IScriptElement> ();
            _elementMock3 = MockRepository.GenerateStrictMock <IScriptElement> ();
        }
コード例 #4
0
        public IScriptElement GetDropScript()
        {
            var scriptElementCollection = new ScriptElementCollection();

            foreach (var scriptBuilder in _scriptBuilders.Reverse())
            {
                scriptElementCollection.AddElement(scriptBuilder.GetDropScript());
            }
            return(scriptElementCollection);
        }
コード例 #5
0
        public IScriptElement GetCreateScript()
        {
            var scriptElementCollection = new ScriptElementCollection();

            foreach (var scriptBuilder in _scriptBuilders)
            {
                scriptElementCollection.AddElement(scriptBuilder.GetCreateScript());
            }
            return(scriptElementCollection);
        }
コード例 #6
0
        public TableScriptBuilder(ITableScriptElementFactory elementFactory, ICommentScriptElementFactory commentFactory)
        {
            ArgumentUtility.CheckNotNull("elementFactory", elementFactory);
            ArgumentUtility.CheckNotNull("commentFactory", commentFactory);

            _elementFactory       = elementFactory;
            _createScriptElements = new ScriptElementCollection();
            _createScriptElements.AddElement(commentFactory.GetCommentElement("Create all tables"));
            _dropScriptElements = new ScriptElementCollection();
            _dropScriptElements.AddElement(commentFactory.GetCommentElement("Drop all tables"));
        }
コード例 #7
0
        public IndexScriptBuilder(IIndexScriptElementFactory indexScriptElementFactory, ICommentScriptElementFactory commentFactory)
        {
            ArgumentUtility.CheckNotNull("indexScriptElementFactory", indexScriptElementFactory);
            ArgumentUtility.CheckNotNull("commentFactory", commentFactory);

            _indexScriptElementFactory = indexScriptElementFactory;
            _createScriptElements      = new ScriptElementCollection();
            _createScriptElements.AddElement(commentFactory.GetCommentElement("Create indexes for tables that were created above"));
            _dropScriptElements = new ScriptElementCollection();
            _dropScriptElements.AddElement(commentFactory.GetCommentElement("Drop all indexes"));
        }
コード例 #8
0
        public override void SetUp()
        {
            base.SetUp();

            _converter          = new ScriptToStringConverter();
            _fakeCreateElements = new ScriptElementCollection();
            _fakeDropElements   = new ScriptElementCollection();
            _scriptBuilderStub  = MockRepository.GenerateStub <IScriptBuilder>();
            _scriptBuilderStub.Stub(stub => stub.GetCreateScript()).Return(_fakeCreateElements);
            _scriptBuilderStub.Stub(stub => stub.GetDropScript()).Return(_fakeDropElements);

            _scriptElement1 = new ScriptStatement("Test1");
            _scriptElement2 = new ScriptStatement("Test2");
        }
コード例 #9
0
        public override void SetUp()
        {
            base.SetUp();

            _builder1Mock = MockRepository.GenerateStrictMock <IScriptBuilder>();
            _builder2Mock = MockRepository.GenerateStrictMock <IScriptBuilder>();

            _fakeStatement1 = new ScriptStatement("Fake1");
            _fakeStatement2 = new ScriptStatement("Fake2");
            _fakeStatement3 = new ScriptStatement("Fake3");

            _fakeResultCollection1 = new ScriptElementCollection();
            _fakeResultCollection1.AddElement(_fakeStatement1);

            _fakeResultCollection2 = new ScriptElementCollection();
            _fakeResultCollection2.AddElement(_fakeStatement2);
            _fakeResultCollection2.AddElement(_fakeStatement3);
        }
コード例 #10
0
        public IScriptElement GetCreateElement(T entityDefinition)
        {
            ArgumentUtility.CheckNotNull("entityDefinition", entityDefinition);

            var statements = new ScriptElementCollection();

            statements.AddElement(CreateBatchDelimiterStatement());
            statements.AddElement(
                new ScriptStatement(
                    string.Format(
                        "CREATE VIEW [{0}].[{1}] ({2})\r\n"
                        + "  {3}AS\r\n{4}{5}",
                        entityDefinition.ViewName.SchemaName ?? DefaultSchema,
                        entityDefinition.ViewName.EntityName,
                        GetColumnList(entityDefinition.GetAllColumns()),
                        UseSchemaBinding(entityDefinition) ? "WITH SCHEMABINDING " : string.Empty,
                        GetSelectStatements(entityDefinition),
                        UseCheckOption(entityDefinition) ? "\r\n  WITH CHECK OPTION" : string.Empty)));
            statements.AddElement(CreateBatchDelimiterStatement());
            return(statements);
        }
コード例 #11
0
        public SynonymScriptBuilder(
            ISynonymScriptElementFactory <TableDefinition> tableViewElementFactory,
            ISynonymScriptElementFactory <UnionViewDefinition> unionViewElementFactory,
            ISynonymScriptElementFactory <FilterViewDefinition> filterViewElementFactory,
            ISynonymScriptElementFactory <EmptyViewDefinition> emptyViewElementFactory,
            ICommentScriptElementFactory commentFactory)
        {
            ArgumentUtility.CheckNotNull("tableViewElementFactory", tableViewElementFactory);
            ArgumentUtility.CheckNotNull("unionViewElementFactory", unionViewElementFactory);
            ArgumentUtility.CheckNotNull("filterViewElementFactory", filterViewElementFactory);
            ArgumentUtility.CheckNotNull("emptyViewElementFactory", emptyViewElementFactory);
            ArgumentUtility.CheckNotNull("commentFactory", commentFactory);

            _tableViewElementFactory  = tableViewElementFactory;
            _unionViewElementFactory  = unionViewElementFactory;
            _filterViewElementFactory = filterViewElementFactory;
            _emptyViewElementFactory  = emptyViewElementFactory;
            _createScriptElements     = new ScriptElementCollection();
            _createScriptElements.AddElement(commentFactory.GetCommentElement("Create synonyms for tables that were created above"));
            _dropScriptElements = new ScriptElementCollection();
            _dropScriptElements.AddElement(commentFactory.GetCommentElement("Drop all synonyms"));
        }
コード例 #12
0
        public ViewScriptBuilder(
            IViewScriptElementFactory <TableDefinition> tableViewElementFactory,
            IViewScriptElementFactory <UnionViewDefinition> unionViewElementFactory,
            IViewScriptElementFactory <FilterViewDefinition> filterViewElementFactory,
            IViewScriptElementFactory <EmptyViewDefinition> emptyViewElementFactory,
            ICommentScriptElementFactory commentFactory)
        {
            ArgumentUtility.CheckNotNull("tableViewElementFactory", tableViewElementFactory);
            ArgumentUtility.CheckNotNull("unionViewElementFactory", unionViewElementFactory);
            ArgumentUtility.CheckNotNull("filterViewElementFactory", filterViewElementFactory);
            ArgumentUtility.CheckNotNull("emptyViewElementFactory", emptyViewElementFactory);
            ArgumentUtility.CheckNotNull("commentFactory", commentFactory);

            _tableViewElementFactory  = tableViewElementFactory;
            _unionViewElementFactory  = unionViewElementFactory;
            _filterViewElementFactory = filterViewElementFactory;
            _emptyViewElementFactory  = emptyViewElementFactory;

            _createScriptElements = new ScriptElementCollection();
            _createScriptElements.AddElement(commentFactory.GetCommentElement("Create a view for every class"));
            _dropScriptElements = new ScriptElementCollection();
            _dropScriptElements.AddElement(commentFactory.GetCommentElement("Drop all views"));
        }