예제 #1
0
        public void TestMove()
        {
            using (var requestHandler = new TestRequestHandler())
                using (var client = new RingMasterClient(requestHandler))
                {
                    string pathSrc        = this.GetRandomString();
                    string pathDst        = this.GetRandomString();
                    var    version        = this.GetRandomInt();
                    var    moveMode       = MoveMode.AllowPathCreationFlag;
                    var    expectedResult = this.GetRandomString();

                    requestHandler.Implementation = request =>
                    {
                        Assert.IsTrue(request is RequestMove);
                        var moveRequest = (RequestMove)request;
                        Assert.AreEqual(pathSrc, moveRequest.Path);
                        Assert.AreEqual(pathDst, moveRequest.PathDst);
                        Assert.AreEqual(version, moveRequest.Version);
                        Assert.AreEqual(moveMode, moveRequest.MoveMode);

                        return(new RequestResponse()
                        {
                            ResultCode = (int)RingMasterException.Code.Ok,
                            Content = expectedResult
                        });
                    };

                    string result = client.Move(pathSrc, version, pathDst, moveMode).Result;
                    Assert.AreEqual(expectedResult, result);
                }
        }