Пример #1
0
 public void Setup()
 {
     _s3ClientMock       = new Mock <IAwsS3Client>();
     _clientProxy.Client = _s3ClientMock.Object;
     _mockService        = MockService.CreateMockService(_hostInfo);
     _storageRoot        = _mockService.Service.Storage.Uri.LastSegment;
 }
 public void Default_public_storage_root_cannot_be_read()
 {
     using (DreamHostInfo hostInfo = DreamTestHelper.CreateRandomPortHost()) {
         MockServiceInfo mock = MockService.CreateMockService(hostInfo);
         mock.Service.CatchAllCallback = delegate(DreamContext context, DreamMessage request, Result <DreamMessage> response2) {
             DreamMessage r = Plug.New((context.Service as MockService).Storage.Uri.WithoutLastSegment()).GetAsync().Wait();
             response2.Return(r);
         };
         DreamMessage response = mock.AtLocalMachine.GetAsync().Wait();
         Assert.AreEqual(DreamStatus.Forbidden, response.Status);
     }
 }
Пример #3
0
        public void XmlAsUriWithDreamContext()
        {
            DreamHostInfo   hostInfo = DreamTestHelper.CreateRandomPortHost();
            MockServiceInfo mock     = MockService.CreateMockService(hostInfo);

            mock.Service.CatchAllCallback = delegate(DreamContext context, DreamMessage request, Result <DreamMessage> response) {
                XUri uri = mock.AtLocalMachine.Uri;
                XDoc doc = new XDoc("test").Elem("uri", uri);
                Assert.AreEqual(uri.AsPublicUri().ToString(), doc["uri"].AsText);
                Assert.AreEqual(uri, doc["uri"].AsUri);
                response.Return(DreamMessage.Ok(doc));
            };
            DreamMessage result = mock.AtLocalMachine.PostAsync().Wait();

            Assert.IsTrue(result.IsSuccessful, "failure in service");
            Assert.AreEqual(mock.AtLocalHost.Uri.WithoutQuery(), result.ToDocument()["uri"].AsUri);
        }