Пример #1
0
 public IWebResponse Invoke(Ds3Request request)
 {
     Assert.AreEqual(_verb, request.Verb);
     Assert.AreEqual(_path, request.Path);
     CollectionAssert.AreEquivalent(_queryParams, request.QueryParams);
     Assert.AreEqual(_requestContent, HelpersForTest.StringFromStream(request.GetContentStream()));
     return(new MockWebResponse(_responseContent, _statusCode, _responseHeaders));
 }
Пример #2
0
        public void TestPutObject()
        {
            var stringRequest       = "object content";
            var jobId               = Guid.Parse("e5d4adce-e170-4915-ba04-595fab30df81");
            var offset              = 10L;
            var expectedQueryParams = new Dictionary <string, string>
            {
                { "job", "e5d4adce-e170-4915-ba04-595fab30df81" },
                { "offset", "10" }
            };

            MockNetwork
            .Expecting(HttpVerb.PUT, "/bucketName/object", expectedQueryParams, stringRequest)
            .Returning(HttpStatusCode.OK, stringRequest, _emptyHeaders)
            .AsClient
            .PutObject(new PutObjectRequest("bucketName", "object", jobId, offset, HelpersForTest.StringToStream(stringRequest)));
        }
Пример #3
0
        private static void CheckJobResponse(JobResponse response)
        {
            var expectedNodes = new[] {
                new {
                    EndPoint  = "10.1.18.12",
                    HttpPort  = (int?)80,
                    HttpsPort = (int?)443,
                    Id        = Guid.Parse("a02053b9-0147-11e4-8d6a-002590c1177c")
                },
                new {
                    EndPoint  = "10.1.18.13",
                    HttpPort  = (int?)null,
                    HttpsPort = (int?)443,
                    Id        = Guid.Parse("4ecebf6f-bfd2-40a8-82a6-32fd684fd500")
                },
                new {
                    EndPoint  = "10.1.18.14",
                    HttpPort  = (int?)80,
                    HttpsPort = (int?)null,
                    Id        = Guid.Parse("4d5b6669-76f0-49f9-bc2a-9280f40cafa7")
                },
            };
            var expectedObjectLists = new[] {
                new {
                    ChunkNumber = 0L,
                    ChunkId     = Guid.Parse("f58370c2-2538-4e78-a9f8-e4d2676bdf44"),
                    NodeId      = (Guid?)Guid.Parse("a02053b9-0147-11e4-8d6a-002590c1177c"),
                    Objects     = new[] {
                        new { Name = "client00obj000004-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000004-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000003-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000003-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000002-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000002-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000005-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000005-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000006-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000006-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000000-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000000-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000001-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000001-8000000", Length = 2823290880L, Offset = 5368709120L },
                    },
                },
                new {
                    ChunkNumber = 1L,
                    ChunkId     = Guid.Parse("4137d768-25bb-4942-9d36-b92dfbe75e01"),
                    NodeId      = (Guid?)null,
                    Objects     = new[] {
                        new { Name = "client00obj000008-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000008-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000009-8000000", Length = 2823290880L, Offset = 5368709120L },
                        new { Name = "client00obj000009-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000007-8000000", Length = 5368709120L, Offset = 0L },
                        new { Name = "client00obj000007-8000000", Length = 2823290880L, Offset = 5368709120L },
                    }
                }
            };

            HelpersForTest.AssertCollectionsEqual(expectedNodes, response.Nodes, (expectedNode, actualNode) =>
            {
                Assert.AreEqual(expectedNode.Id, actualNode.Id);
                Assert.AreEqual(expectedNode.EndPoint, actualNode.EndPoint);
                Assert.AreEqual(expectedNode.HttpPort, actualNode.HttpPort);
                Assert.AreEqual(expectedNode.HttpsPort, actualNode.HttpsPort);
            });
            HelpersForTest.AssertCollectionsEqual(expectedObjectLists, response.ObjectLists, (expectedObjectList, actualObjectList) =>
            {
                Assert.AreEqual(expectedObjectList.ChunkNumber, actualObjectList.ChunkNumber);
                Assert.AreEqual(expectedObjectList.ChunkId, actualObjectList.ChunkId);
                Assert.AreEqual(expectedObjectList.NodeId, actualObjectList.NodeId);
                HelpersForTest.AssertCollectionsEqual(expectedObjectList.Objects, actualObjectList.Objects, (expectedObject, actualObject) =>
                {
                    Assert.AreEqual(expectedObject.Name, actualObject.Name);
                    Assert.AreEqual(expectedObject.Length, actualObject.Length);
                    Assert.AreEqual(expectedObject.Offset, actualObject.Offset);
                });
            });
        }
Пример #4
0
 public Stream GetResponseStream()
 {
     return(HelpersForTest.StringToStream(_responseString));
 }