public void DeleteNodesAsync()
        {
            var nodesTDelete    = new DeleteNodesItemCollection();
            var deleteNodesItem = new DeleteNodesItem()
            {
            };

            for (int ii = 0; ii < kOperationLimit * 2; ii++)
            {
                nodesTDelete.Add(deleteNodesItem);
            }

            var requestHeader = new RequestHeader();
            var sre           = Assert.ThrowsAsync <ServiceResultException>(async() => {
                var response = await Session.DeleteNodesAsync(requestHeader,
                                                              nodesTDelete, CancellationToken.None).ConfigureAwait(false);

                StatusCodeCollection results             = response.Results;
                DiagnosticInfoCollection diagnosticInfos = response.DiagnosticInfos;

                Assert.NotNull(response.ResponseHeader);
                Assert.AreEqual(nodesTDelete.Count, results.Count);
                Assert.AreEqual(diagnosticInfos.Count, diagnosticInfos.Count);
            });

            Assert.AreEqual(StatusCodes.BadServiceUnsupported, sre.StatusCode);
        }
        public void DeleteNodes()
        {
            var nodesTDelete    = new DeleteNodesItemCollection();
            var deleteNodesItem = new DeleteNodesItem()
            {
            };

            for (int ii = 0; ii < kOperationLimit * 2; ii++)
            {
                nodesTDelete.Add(deleteNodesItem);
            }

            var requestHeader = new RequestHeader();
            var sre           = Assert.Throws <ServiceResultException>(() => {
                var responseHeader = Session.DeleteNodes(requestHeader,
                                                         nodesTDelete,
                                                         out StatusCodeCollection results,
                                                         out DiagnosticInfoCollection diagnosticInfos);

                Assert.NotNull(responseHeader);
                Assert.AreEqual(nodesTDelete.Count, results.Count);
                Assert.AreEqual(diagnosticInfos.Count, diagnosticInfos.Count);
            });

            Assert.AreEqual(StatusCodes.BadServiceUnsupported, sre.StatusCode);
        }
Beispiel #3
0
        /// <summary>
        /// 删除一个节点的操作,除非服务器配置允许,否则引发异常,成功返回<c>True</c>,否则返回<c>False</c>
        /// </summary>
        /// <param name="tag">节点文本描述</param>
        /// <returns></returns>
        public bool DeleteExsistNode(string tag)
        {
            DeleteNodesItemCollection waitDelete = new DeleteNodesItemCollection( );

            DeleteNodesItem nodesItem = new DeleteNodesItem( )
            {
                NodeId = new NodeId(tag),
            };

            m_session.DeleteNodes(
                null,
                waitDelete,
                out StatusCodeCollection results,
                out DiagnosticInfoCollection diagnosticInfos);

            ClientBase.ValidateResponse(results, waitDelete);
            ClientBase.ValidateDiagnosticInfos(diagnosticInfos, waitDelete);

            return(!StatusCode.IsBad(results[0]));
        }