Opc.Ua.ServerTest.TestBase.VerifyVariableConsistency C# (CSharp) Method

VerifyVariableConsistency() private method

Verifies that the variable attributes are consistent with each other.
private VerifyVariableConsistency ( IVariable node ) : bool
node IVariable
return bool
        private bool VerifyVariableConsistency(IVariable node)
        {
            if (((~node.AccessLevel) & node.UserAccessLevel) != 0)
            {
                Log(
                    "UserAccessLevel allows more access that AccessLevel for  Node '{0}'. NodeId = {1}, WriteMask = {2}, UserWriteMask = {3}",
                    node,
                    node.NodeId,
                    node.AccessLevel,
                    node.UserAccessLevel);

                return false;
            }

            if (node.MinimumSamplingInterval < -1)
            {
                Log(
                    "MinimumSamplingInterval is inavlid for  Node '{0}'. NodeId = {1}, MinimumSamplingInterval = {2}",
                    node,
                    node.NodeId,
                    node.MinimumSamplingInterval);

                return false;
            }
            
            // check for error during read.
            StatusCode? status = node.Value as StatusCode?;

            if (status != null)
            {
                if (status.Value == StatusCodes.BadUserAccessDenied)
                {
                    if ((node.UserAccessLevel & AccessLevels.CurrentRead) != 0)
                    {
                        Log(
                            "UserAccessLevel allows CurrentRead but server returned BadUserAccessDenied for Node '{0}'. NodeId = {1}",
                            node,
                            node.NodeId);

                        return false;
                    }
                }

                if (status.Value == StatusCodes.BadNotReadable)
                {
                    if ((node.AccessLevel & AccessLevels.CurrentRead) != 0)
                    {
                        Log(
                            "AccessLevel allows CurrentRead but server returned BadNotReadable for Node '{0}'. NodeId = {1}",
                            node,
                            node.NodeId);

                        return false;
                    }
                }
            }

            // check data type.
            else
            {
                TypeInfo typeInfo = TypeInfo.IsInstanceOfDataType(
                    node.Value,
                    node.DataType,
                    node.ValueRank,
                    Session.NamespaceUris,
                    Session.TypeTree);

                if (typeInfo == null)
                {
                    Log(
                        "Value has incorrect data type for Node '{0}'. NodeId = {1}, DataType = {2}, ValueRank = {3}, Value = {4}",
                        node,
                        node.NodeId,
                        node.DataType,
                        node.ValueRank,
                        new Variant(node.Value));

                    return false;
                }
            }

            return true;
        }