Пример #1
0
        public void ToApiCopyNodesRequest()
        {
            // ARRANGE
            ApiCopyNodesRequest expected = FactoryNode.ApiCopyNodesRequest;

            expected.ResolutionStrategy = "overwrite";

            CopyNodesRequest param = new CopyNodesRequest(2,
                                                          new List <CopyNode>(expected.Nodes.Count),
                                                          ResolutionStrategy.Overwrite,
                                                          expected.KeepShareLinks);

            foreach (ApiCopyNode currentApi in expected.Nodes)
            {
                param.NodesToBeCopied.Add(new CopyNode(currentApi.NodeId, currentApi.NewName));
            }

            Mock.Arrange(() => EnumConverter.ConvertResolutionStrategyToValue(param.ResolutionStrategy)).Returns(expected.ResolutionStrategy);

            // ACT
            ApiCopyNodesRequest actual = NodeMapper.ToApiCopyNodesRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiCopyNodesRequestComparer());
        }
Пример #2
0
        public Node CopyNodes(CopyNodesRequest request)
        {
            _client.Executor.CheckApiServerVersion();

            #region Parameter Validation

            request.MustNotNull(nameof(request));
            request.TargetNodeId.MustPositive(nameof(request.TargetNodeId));
            request.NodesToBeCopied.EnumerableMustNotNullOrEmpty(nameof(request.NodesToBeCopied));
            request.NodesToBeCopied.ForEach(current => current.NodeId.MustPositive(nameof(current.NodeId)));

            #endregion

            ApiCopyNodesRequest apiCopyNodesRequest = NodeMapper.ToApiCopyNodesRequest(request);
            IRestRequest        restRequest         = _client.Builder.PostCopyNodes(request.TargetNodeId, apiCopyNodesRequest);
            ApiNode             result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PostCopyNodes);
            return(NodeMapper.FromApiNode(result));
        }