public void PersistSQLparamaterValue_WhenByteArrayNull_WhenSQLServer_ShouldNotExist_FIXBUG1741()
        {
            //---------------Set up test pack-------------------
            var loader   = new XmlClassLoader(new DtdLoader(), new DefClassFactory());
            var classDef = loader.LoadClass(@"
					<class name=""MyBO"" assembly=""Habanero.Test"">
						<property  name=""MyBoID"" type=""Guid"" />
						<property  name=""ByteArrayProp"" type=""Byte[]"" />
						<primaryKey>
							<prop name=""MyBoID"" />
						</primaryKey>
					</class>
				"                );

            ClassDef.ClassDefs.Clear();
            ClassDef.ClassDefs.Add(classDef);
            var bo = classDef.CreateNewBusinessObject();

            bo.SetPropertyValue("ByteArrayProp", null);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var sqlCol       = new TransactionalBusinessObjectDB(bo, DatabaseConnection.CurrentConnection).GetPersistSql();
            var sqlStatement = sqlCol.First();

            //IList parameters = sqlStatement.Parameters;

            DatabaseConnection.CurrentConnection.ExecuteSql(sqlStatement);
            //---------------Test Result -----------------------
            Assert.Pass("If it got here then it is OK");
        }
예제 #2
0
        public void TestPersistSqlParameterType()
        {
            TestUsingDatabase.SetupDBOracleConnection();
            IBusinessObject bo            = _itsClassDef.CreateNewBusinessObject();
            StringBuilder   stringBuilder = new StringBuilder();

            stringBuilder.Append('*', 2500);
            string value = stringBuilder.ToString();

            bo.SetPropertyValue("TestProp", value);
            var              sqlCol               = new TransactionalBusinessObjectDB(bo, DatabaseConnection.CurrentConnection).GetPersistSql();
            ISqlStatement    sqlStatement         = sqlCol.First();
            IList            parameters           = sqlStatement.Parameters;
            IDbDataParameter longTextParam        = (IDbDataParameter)parameters[1];
            string           oracleTypeEnumString = ReflectionUtilities.GetEnumPropertyValue(longTextParam, "OracleType");

            Assert.IsTrue(oracleTypeEnumString == "Clob");
        }
예제 #3
0
        public void PersistSQLparamaterValue_WhenByteArrayNull_WhenMySQL_ShouldNotExist_FIXBUG1741()
        {
            //---------------Set up test pack-------------------
            TestUsingDatabase.SetupDBDataAccessor();
            var bo = _classDef.CreateNewBusinessObject();

            bo.SetPropertyValue("ByteArrayProp", null);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var sqlCol       = new TransactionalBusinessObjectDB(bo, DatabaseConnection.CurrentConnection).GetPersistSql();
            var sqlStatement = sqlCol.First();

            //IList parameters = sqlStatement.Parameters;

            DatabaseConnection.CurrentConnection.ExecuteSql(sqlStatement);
            //---------------Test Result -----------------------
            Assert.Pass("If it got here then it is OK");
        }
        public void Test_UsingGivenDatabaseConnection_Insert()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            MyBO.LoadDefaultClassDef();
            MyBO bo = new MyBO();

            DatabaseConnection.CurrentConnection = null;

            //---------------Assert preconditions---------------
            Assert.AreNotSame(_databaseConnection, DatabaseConnection.CurrentConnection);

            //---------------Execute Test ----------------------
            TransactionalBusinessObjectDB transactional = new TransactionalBusinessObjectDB(bo, _databaseConnection);
            SqlStatement sqlStatement = (SqlStatement)transactional.GetPersistSql().FirstOrDefault();

            //---------------Test Result -----------------------
            Assert.AreSame(_databaseConnection, sqlStatement.Connection);
            //---------------Tear down -------------------------
        }
예제 #5
0
        public void TestTransactionLogPersistsSQL_AddedToBusinessObjectPersistsSql()
        {
            //---------------Set up test pack-------------------
            //Create Mock Business object that implements a stub transaction log.
            ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging();
            TransactionalBusinessObjectDB   transactionalBODB = new TransactionalBusinessObjectDB(cp, DatabaseConnection.CurrentConnection);

            //---------------Assert Preconditions --------------

            //---------------Execute Test ----------------------
            var sqlStatementCollection = transactionalBODB.GetPersistSql();
            //---------------Test Result -----------------------
            //check if the transaction committer has 2 object
            // check that the one object is the transaction log object.
            var sqlStatements = sqlStatementCollection.ToList();

            Assert.AreEqual(2, sqlStatements.Count);
            ISqlStatement       sqlStatement        = sqlStatements[1];
            TransactionLogTable transactionLogTable = new TransactionLogTable(cp);

            Assert.AreEqual(transactionLogTable.GetPersistSql().First().Statement.ToString(), sqlStatement.Statement.ToString());
        }
예제 #6
0
        public void TestPersistSqlParameterValue()
        {
            TestUsingDatabase.SetupDBOracleConnection();
            IBusinessObject bo = _classDef.CreateNewBusinessObject();

            bo.SetPropertyValue("TestProp", "test");
            var              sqlCol          = new TransactionalBusinessObjectDB(bo, DatabaseConnection.CurrentConnection).GetPersistSql();
            ISqlStatement    sqlStatement    = sqlCol.First();
            IList            parameters      = sqlStatement.Parameters;
            IDbDataParameter byteStringParam = (IDbDataParameter)parameters[2];

            Assert.IsTrue(byteStringParam.Value is byte[], "Should be a byte array");
            byte[] paramValue = (byte[])byteStringParam.Value;
            Assert.AreEqual(paramValue.Length, itsByteArrSpelling_test.Length);
            Assert.AreEqual(paramValue[0], itsByteArrSpelling_test[0]);
            Assert.AreEqual(paramValue[1], itsByteArrSpelling_test[1]);
            Assert.AreEqual(paramValue[2], itsByteArrSpelling_test[2]);
            Assert.AreEqual(paramValue[3], itsByteArrSpelling_test[3]);
            Assert.AreEqual(paramValue[4], itsByteArrSpelling_test[4]);
            Assert.AreEqual(paramValue[5], itsByteArrSpelling_test[5]);
            Assert.AreEqual(paramValue[6], itsByteArrSpelling_test[6]);
            Assert.AreEqual(paramValue[7], itsByteArrSpelling_test[7]);
        }
예제 #7
0
        public void TestTransactionLogPersistsSQL_NotAddedToBusinessObjectPersistsSql_WhenObjectUnchanged()
        {
            //---------------Set up test pack-------------------
            //Create Mock Business object that implements a stub transaction log.
            ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging();
            TransactionCommitterStub        tc = new TransactionCommitterStub();

            tc.AddBusinessObject(cp);
            tc.CommitTransaction();
            TransactionalBusinessObjectDB transactionalBODB = new TransactionalBusinessObjectDB(cp, DatabaseConnection.CurrentConnection);

            //---------------Assert Preconditions --------------

            //---------------Execute Test ----------------------
            IEnumerable <ISqlStatement> sqlStatementCollection = transactionalBODB.GetPersistSql();

            //---------------Test Result -----------------------
            //check if the transaction committer has 2 object
            // check that the one object is the transaction log object.
            Assert.AreEqual(0, sqlStatementCollection.Count());
            //ISqlStatement sqlStatement = sqlStatementCollection[1];
            //TransactionLogTable transactionLogTable = new TransactionLogTable(cp);
            //Assert.AreEqual(transactionLogTable.GetPersistSql()[0].Statement.ToString(), sqlStatement.Statement.ToString());
        }
        protected override void ExecuteTransactionToDataSource(ITransactional transaction)
        {
            TransactionalBusinessObjectDB transactionDB = (TransactionalBusinessObjectDB)transaction;

            transactionDB.GetPersistSql();
        }