Opc.Ua.ServerTest.WriteTest.DoWriteBadTypeTest C# (CSharp) Method

DoWriteBadTypeTest() private method

Reads an verifies all of the nodes.
private DoWriteBadTypeTest ( ) : bool
return bool
        private bool DoWriteBadTypeTest()
        {
            // follow tree from each starting node.
            bool success = true;

            // collection writeable variables that don't change during the test.
            List<TestVariable> variables = new List<TestVariable>();

            for (int ii = 0; ii < WriteableVariables.Count; ii++)
            {
                TestVariable test = new TestVariable();

                test.Variable = WriteableVariables[ii];
                test.DataType = TypeInfo.GetBuiltInType(WriteableVariables[ii].DataType, Session.TypeTree);
                test.Values = new List<DataValue>();

                variables.Add(test);
            }

            Log("Starting WriteBadTypeTest for {0} Nodes", variables.Count);
            
            double increment = MaxProgress/variables.Count;
            double position  = 0;

            WriteValueCollection nodesToWrite = new WriteValueCollection();
            
            int nodes = 0;
            int operations = 0;

            foreach (TestVariable variable in variables)
            {               
                nodes++;

                AddWriteBadValues(variable, nodesToWrite);

                // process batch.
                if (nodesToWrite.Count > 100)
                {
                    operations += nodesToWrite.Count;

                    if (!WriteBadValues(nodesToWrite))
                    {
                        success = false;
                        break;
                    }

                    if (nodes > variables.Count/5)
                    {
                        Log("Wrote {0} attribute values for {1} nodes.", operations, nodes);
                        nodes = 0;
                        operations = 0;
                    }

                    nodesToWrite.Clear();
                }

                position += increment;
                ReportProgress(position);
            }   
         
            // process final batch.
            if (success)
            {
                if (nodesToWrite.Count > 0)
                {
                    operations += nodesToWrite.Count;

                    if (!WriteBadValues(nodesToWrite))
                    {
                        success = false;
                    }
                    else
                    {
                        Log("Wrote {0} attribute values for {1} nodes.", operations, nodes);
                    }

                    nodesToWrite.Clear();
                }
            }

            return success;
        }
        #endregion