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

            expected.ResolutionStrategy = "overwrite";

            MoveNodesRequest param = new MoveNodesRequest(12,
                                                          new List <MoveNode>(expected.Nodes.Count),
                                                          ResolutionStrategy.Overwrite,
                                                          expected.KeepShareLinks);

            foreach (ApiMoveNode currentApi in expected.Nodes)
            {
                param.NodesToBeMoved.Add(new MoveNode(currentApi.NodeId, currentApi.NewName));
            }

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

            // ACT
            ApiMoveNodesRequest actual = NodeMapper.ToApiMoveNodesRequest(param);

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

            #region Parameter Validation

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

            #endregion

            ApiMoveNodesRequest apiMoveNodesRequest = NodeMapper.ToApiMoveNodesRequest(request);
            IRestRequest        restRequest         = _client.Builder.PostMoveNodes(request.TargetNodeId, apiMoveNodesRequest);
            ApiNode             result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PostMoveNodes);
            return(NodeMapper.FromApiNode(result));
        }