Example #1
0
        public void LoadBasicData()
        {
            CheckDisposed();

            int hvoPhm_17_21 = 0;

            IOleDbCommand odc = null;

            try
            {
                m_fdoCache.DatabaseAccessor.CreateCommand(out odc);
                string sSql = @"select id from StTxtPara_ " +
                              @"where Owner$ = (select dst from scrsection_content c " +
                              @"join scrSection s on c.src = s.id " +
                              @"where s.VerseRefStart = 57001001) " +
                              @"and substring(contents, 1, 2) = '17'";
                odc.ExecCommand(sSql,
                                (int)SqlStmtType.knSqlStmtSelectWithOneRowset);
                odc.GetRowset(0);
                bool fMoreRows;
                odc.NextRow(out fMoreRows);
                if (fMoreRows)
                {
                    odc.GetInt(1, out hvoPhm_17_21);
                }
            }
            finally
            {
                DbOps.ShutdownODC(ref odc);
            }
            //			SqlConnection sqlConMaster = new SqlConnection(
            //				string.Format("Server={0}; Database={1};" +
            //				"User ID = sa; Password=inscrutable; Pooling=false;",
            //				m_fdoCache.ServerName, m_fdoCache.DatabaseName));
            //			sqlConMaster.Open();
            //			SqlCommand sqlComm = sqlConMaster.CreateCommand();
            //			// Select the hvo of the paragraph containing Philemon 17-21.
            //			string sSql = @"select id from StTxtPara_ " +
            //				@"where Owner$ = (select dst from scrsection_content c " +
            //				@"join scrSection s on c.src = s.id " +
            //				@"where s.VerseRefStart = 57001001) " +
            //				@"and substring(contents, 1, 2) = '17'";
            //			sqlComm.CommandText = sSql;
            //			SqlDataReader sqlreader =
            //				sqlComm.ExecuteReader(System.Data.CommandBehavior.SingleResult);
            //			if (sqlreader.Read())
            //				hvoPhm_17_21 = sqlreader.GetInt32(0);
            //
            //			sqlreader.Close();
            //			sqlreader = null;
            //			sqlComm.Dispose();
            //			sqlComm = null;
            //			sqlConMaster.Close();
            //			sqlConMaster.Dispose();
            //			sqlConMaster = null;

            Assert.IsTrue(hvoPhm_17_21 > 0);

            NewStPara.s_fPopCalledInNewStPara = false;
            m_fdoCache.VwCacheDaAccessor.ClearInfoAbout(hvoPhm_17_21,
                                                        VwClearInfoAction.kciaRemoveObjectInfoOnly);
            NewStPara para = new NewStPara(m_fdoCache, hvoPhm_17_21);

            Assert.IsTrue(NewStPara.s_fPopCalledInNewStPara,
                          "PopulateCsBasic wasn't called in NewStPara");
            Assert.IsNotNull(para.Contents, "Contents of NewStPara is null");

            DerivedStTxtPara2.s_fPopCalledInNewStPara = false;
            DerivedStTxtPara2.s_fPopCalledInDerived   = false;
            m_fdoCache.VwCacheDaAccessor.ClearInfoAbout(hvoPhm_17_21,
                                                        VwClearInfoAction.kciaRemoveObjectInfoOnly);
            DerivedStTxtPara2 para2 = new DerivedStTxtPara2(m_fdoCache, hvoPhm_17_21);

            Assert.IsFalse(DerivedStTxtPara2.s_fPopCalledInNewStPara,
                           "PopulateCsBasic was called in NewStPara instead of DerivedStTxtPara2");
            Assert.IsTrue(DerivedStTxtPara2.s_fPopCalledInDerived,
                          "PoplulateCsBasic wasn't called in DerviedStTxtPara2");
            Assert.IsNotNull(para.Contents, "Contents of DerivedStTxtPara2 is null");

            DerivedStTxtPara.s_fPopCalledInNewStPara = false;
            m_fdoCache.VwCacheDaAccessor.ClearInfoAbout(hvoPhm_17_21,
                                                        VwClearInfoAction.kciaRemoveObjectInfoOnly);
            DerivedStTxtPara para3 = new DerivedStTxtPara(m_fdoCache, hvoPhm_17_21);

            Assert.IsTrue(DerivedStTxtPara.s_fPopCalledInNewStPara,
                          "PoplulateCsBasic wasn't called in DerviedStTxtPara");
            Assert.IsNotNull(para.Contents, "Contents of DerivedStTxtPara is null");
        }