public void Setup() { _s3ClientMock = new Mock <IAwsS3Client>(); _clientProxy.Client = _s3ClientMock.Object; _mockService = MockService.CreateMockService(_hostInfo); _storageRoot = _mockService.Service.Storage.Uri.LastSegment; }
//--- Extension Methods Methods --- public static DreamMessage CallStorage(this MockServiceInfo mock, Func <Plug, Result <DreamMessage> > mockCall) { mock.Service.CatchAllCallback = (context, request, response2) => { var storage = (context.Service as MockService).Storage; response2.Return(mockCall(storage).Wait()); }; return(mock.AtLocalMachine.Get(new Result <DreamMessage>()).Wait()); }
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); } }
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); }
public void Setup() { _s3ClientMock = null; _mockService = MockService.CreateMockServiceWithPrivateStorage(_hostInfo); _storageRoot = _mockService.Service.Storage.Uri.LastSegment; }