Ejemplo n.º 1
0
        public void ShouldNotInsertBeginOrEndTransactionStatementIfPropertyIsNotSet()
        {
            const string deltaScriptContent = @"foo bar";

            using (StreamWriter stream = script.GetFile().CreateText())
                stream.Write(deltaScriptContent);

            StringWriter         writer   = new StringWriter();
            MsSqlDbmsSyntax      syntax   = new MsSqlDbmsSyntax("changeOwner");
            ChangeScriptExecuter executer = new ChangeScriptExecuter(writer, syntax, false);

            executer.ApplyChangeDoScript(script);

            string deltaFragment = writer.ToString();

            System.Console.Write(deltaFragment);

            int beingIndex = deltaFragment.IndexOf(syntax.GenerateBeginTransaction());

            Assert.AreEqual(-1, beingIndex);

            int endIndex = deltaFragment.IndexOf(syntax.GenerateCommitTransaction());

            Assert.AreEqual(-1, endIndex);
        }
    	public void ShouldInsertBeginAndEndTransactionStatementsForEachDelta()
    	{
			const string deltaScriptContent = @"foo bar";
			using (StreamWriter stream = script.GetFile().CreateText())
				stream.Write(deltaScriptContent);

    		StringWriter writer = new StringWriter();
    		MsSqlDbmsSyntax syntax = new MsSqlDbmsSyntax();
    		ChangeScriptExecuter executer = new ChangeScriptExecuter(writer, syntax, true);
			executer.ApplyChangeDoScript(script);

    		string deltaFragment = writer.ToString();

			Console.Write(deltaFragment);

			string expectedBegin = syntax.GenerateBeginTransaction();
			int startOfBegin = deltaFragment.IndexOf(deltaScriptContent) - expectedBegin.Length - Environment.NewLine.Length;
    		string resultBegin = deltaFragment.Substring(startOfBegin, expectedBegin.Length);

			Assert.AreEqual(expectedBegin, resultBegin);

			string expectedCommit = syntax.GenerateCommitTransaction();
			int startOfCommit = deltaFragment.IndexOf(deltaScriptContent) + deltaScriptContent.Length + Environment.NewLine.Length;
			string resultCommit = deltaFragment.Substring(startOfCommit, expectedCommit.Length);

			Assert.AreEqual(expectedCommit, resultCommit);
		}
Ejemplo n.º 3
0
        public void ShouldInsertBeginAndEndTransactionStatementsForEachDelta()
        {
            const string deltaScriptContent = @"foo bar";

            using (StreamWriter stream = script.GetFile().CreateText())
                stream.Write(deltaScriptContent);

            StringWriter         writer   = new StringWriter();
            MsSqlDbmsSyntax      syntax   = new MsSqlDbmsSyntax("changeOwner");
            ChangeScriptExecuter executer = new ChangeScriptExecuter(writer, syntax, true);

            executer.ApplyChangeDoScript(script);

            string deltaFragment = writer.ToString();


            System.Console.Write(deltaFragment);

            string expectedBegin = syntax.GenerateBeginTransaction();
            int    startOfBegin  = deltaFragment.IndexOf(deltaScriptContent) - expectedBegin.Length - Environment.NewLine.Length;
            string resultBegin   = deltaFragment.Substring(startOfBegin, expectedBegin.Length);

            Assert.AreEqual(expectedBegin, resultBegin);

            string expectedCommit = syntax.GenerateCommitTransaction();
            int    startOfCommit  = deltaFragment.IndexOf(deltaScriptContent) + deltaScriptContent.Length + Environment.NewLine.Length;
            string resultCommit   = deltaFragment.Substring(startOfCommit, expectedCommit.Length);

            Assert.AreEqual(expectedCommit, resultCommit);
        }
    	public void ShouldNotInsertBeginOrEndTransactionStatementIfPropertyIsNotSet()
    	{
			const string deltaScriptContent = @"foo bar";
			using (StreamWriter stream = script.GetFile().CreateText())
				stream.Write(deltaScriptContent);

			StringWriter writer = new StringWriter();
			MsSqlDbmsSyntax syntax = new MsSqlDbmsSyntax();
			ChangeScriptExecuter executer = new ChangeScriptExecuter(writer, syntax, false);
			executer.ApplyChangeDoScript(script);

			string deltaFragment = writer.ToString();

			Console.Write(deltaFragment);

    		int beingIndex = deltaFragment.IndexOf(syntax.GenerateBeginTransaction());
			Assert.AreEqual(-1, beingIndex);

    		int endIndex = deltaFragment.IndexOf(syntax.GenerateCommitTransaction());
			Assert.AreEqual(-1, endIndex);
		}