Beispiel #1
0
        }        //ctor

        public override void update()
        {
            _CswTstCaseRsrc = new CswTestCaseRsrc(_CswNbtSchemaModTrnsctn);
            _CswTstCaseRsrc_014.CswNbtSchemaModTrnsctn = _CswNbtSchemaModTrnsctn;


            CswTableSelect CswTableSelectNodeTypes = _CswNbtSchemaModTrnsctn.makeCswTableSelect(Description, "nodetypes");
            DataTable      NodetypesTable          = CswTableSelectNodeTypes.getTable(" where lower(tablename)='materials'");
            Int32          NodeTypeId = Convert.ToInt32(NodetypesTable.Rows[0]["nodetypeid"]);

            CswNbtMetaDataNodeType NodeType       = _CswNbtSchemaModTrnsctn.MetaData.getNodeType(NodeTypeId);
            CswTableUpdate         CswTableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate(Description, NodeType.TableName);
            string PkColumnName = _CswNbtSchemaModTrnsctn.getPrimeKeyColName(NodeType.TableName);

            //bz # 9102: This is the way of getting the record that causes the updated record disappear
            CswCommaDelimitedString SelectColumns = null; //new CswCommaDelimitedString();
            //foreach( CswNbtMetaDataNodeTypeProp CurrentNodeTypeProp in NodeType.getNodeTypeProps() )
            //{
            //    foreach( CswNbtSubField CurrentSubField in CurrentNodeTypeProp.getFieldTypeRule().SubFields )
            //    {
            //        if( CurrentSubField.RelationalColumn != string.Empty )
            //            SelectColumns.Add( CurrentSubField.RelationalColumn );
            //    }
            //}//iterate node type props to set up select columns
            DataTable DataTable = CswTableUpdate.getTable(SelectColumns, PkColumnName, _CswTstCaseRsrc_014.InsertedMaterialsRecordPk, string.Empty, false);

            DataTable.Rows[0]["materialname"] = "nu _CswTstCaseRsrc_014.Purpose";

            CswTableUpdate.update(DataTable);
        }
        }//ctor

        public override void update()
        {
            _CswTstCaseRsrc = new CswTestCaseRsrc(_CswNbtSchemaModTrnsctn);
            _CswTstCaseRsrc_010.CswNbtSchemaModTrnsctn = _CswNbtSchemaModTrnsctn;
            //Int32 MaterialsPk = Int32.MinValue;


            //SETUP: BEGIN *****************************************
            //Step 1: Make the nodetype ****************************
            Int32                     TestByteArraySize    = 256;
            string                    BlobNodeTypeName     = "TestForBlobNodeType";
            string                    BlobPropName         = "The Blob";
            CswNbtMetaData            CswNbtMetaData       = _CswNbtSchemaModTrnsctn.MetaData;
            CswNbtMetaDataObjectClass GenericObjectClass   = CswNbtMetaData.getObjectClass(CswEnumNbtObjectClass.GenericClass);
            CswNbtMetaDataNodeType    BlobNodeTypeNodeType = CswNbtMetaData.makeNewNodeTypeNew(new CswNbtWcfMetaDataModel.NodeType(GenericObjectClass)
            {
                NodeTypeName = BlobNodeTypeName,
                Category     = string.Empty
            });
            CswNbtMetaDataNodeTypeProp BlobNodeTypeNodeTypeProp = CswNbtMetaData.makeNewPropNew(
                new CswNbtWcfMetaDataModel.NodeTypeProp(BlobNodeTypeNodeType, _CswNbtSchemaModTrnsctn.MetaData.getFieldType(CswEnumNbtFieldType.Image), BlobPropName));


            _CswNbtSchemaModTrnsctn.MetaData.refreshAll();

            if (null == _CswNbtSchemaModTrnsctn.MetaData.getNodeType(BlobNodeTypeName))
            {
                throw (new CswDniException("Nodetype " + BlobNodeTypeName + " was not created; test cannot proceed"));
            }

            //Step 1: Make a node ****************************
            CswNbtNode     BlobNode          = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId(BlobNodeTypeNodeType.NodeTypeId);
            Int32          BlobJctNodePropId = BlobNode.Properties[BlobNodeTypeNodeTypeProp].JctNodePropId;
            CswTableUpdate JctUpdate         = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("CswScmUpdt_TstCse_DataTable_PreserveBlobColumns_1", "jct_nodes_props");

            JctUpdate.AllowBlobColumns = true;
            DataTable JctTable = JctUpdate.getTable("jctnodepropid", BlobJctNodePropId);

            JctTable.Rows[0]["blobdata"] = new Byte[TestByteArraySize];
            JctTable.Rows[0]["field1"]   = "Dummy File Name";
            JctTable.Rows[0]["field2"]   = "Dummy File Type";
            JctUpdate.update(JctTable);


            //SETUP: END *****************************************



            //*** TEST PART 1: That we don't nuke the blob column when select columns are unspecified
            JctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("01G02_JctNodesProps_update", "jct_nodes_props");

            JctTable = JctUpdate.getTable();
            foreach (DataRow JctRow in JctTable.Rows)
            {
                JctRow["nodeidtablename"] = "nodes";
            }
            JctUpdate.update(JctTable);


            CswTableSelect CswTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect("CswScmUpdt_TstCse_DataTable_PreserveBlobColumns_2", "jct_nodes_props");
            DataTable      DataTable      = CswTableSelect.getTable(" where blobdata is not null  ");

            if (0 == DataTable.Rows.Count)
            {
                throw (new CswDniException("A generic update of jct_nodes_props nuked the blob columns"));
            }


            //*** TEST PART 2: That we can retrieve and update the blob column when we use the AllowBlob flag
            //***              Note that in the setup sections we implciitly tested that we can retrieve and
            //***              update the blob column when set the AllowBlobFlag.
            JctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("01G02_JctNodesProps_update", "jct_nodes_props");

            CswCommaDelimitedString SelectColumns = new CswCommaDelimitedString();

            SelectColumns.Add("field1");
            SelectColumns.Add("field2");
            SelectColumns.Add("blobdata");
            JctTable = JctUpdate.getTable(SelectColumns);

            if (false == JctTable.Columns.Contains("blobdata"))
            {
                throw (new CswDniException("Blob column was not retrieved when it was specified as a select column"));
            }


            Byte[] TestByteArray = new Byte[TestByteArraySize]; // update an arbitrary row

            for (int idx = 0; idx < TestByteArraySize; idx++)
            {
                TestByteArray[idx] = 1;
            }

            JctTable.Rows[0]["blobdata"] = TestByteArray;
            Int32 Arbitraryjctnodepropid = Convert.ToInt32(JctTable.Rows[0]["jctnodepropid"]);

            JctUpdate.update(JctTable);


            CswTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect("CswScmUpdt_TstCse_DataTable_PreserveBlobColumns_2", "jct_nodes_props");
            DataTable      = CswTableSelect.getTable(" where jctnodepropid=  " + Arbitraryjctnodepropid.ToString() + "and blobdata is not null ");

            if (0 == DataTable.Rows.Count)
            {
                throw (new CswDniException("An update of a blob column with specified select columns failed"));
            }


            throw (new CswDniExceptionIgnoreDeliberately());
        }