public async Task GetRawResult_ValidRequestGiven_ShouldReturnResult() { const string expectedResultXml = "<wps:LiteralValue xmlns:wps=\"http://www.opengis.net/wps/2.0\" dataType=\"https://www.w3.org/2001/XMLSchema-datatypes#string\">150</wps:LiteralValue>"; var request = new ExecuteRequest { Inputs = new[] { new DataInput { Data = new LiteralDataValue { Value = "test" } } }, ExecutionMode = ExecutionMode.Synchronous, ResponseType = ResponseType.Raw }; var expectedRequestXml = new XmlSerializationService().Serialize(request); var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(expectedResultXml, HttpStatusCode.OK, expectedRequestXml)), new XmlSerializationService()); var result = await wpsClient.GetRawResult(MockUri, request); result.Should().Be(expectedResultXml); }
public async Task AsyncGetDocumentedResult_ValidRequestGiven_ShouldReturnResult(string expectedHttpResponse) { var request = new ExecuteRequest { Identifier = "org.n52.javaps.test.EchoProcess", Inputs = new[] { new DataInput { Data = new LiteralDataValue { Value = "test" } } }, Outputs = new [] { new DataOutput { MimeType = "text/xml" } }, ExecutionMode = ExecutionMode.Asynchronous, ResponseType = ResponseType.Document }; var expectedRequestXml = new XmlSerializationService().Serialize(request); var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(expectedHttpResponse, HttpStatusCode.OK, expectedRequestXml)), new XmlSerializationService()); var session = await wpsClient.AsyncGetDocumentResultAs <LiteralDataValue>(MockUri, request); session.Should().NotBeNull(); session.JobId.Should().Be("test-job-id"); }
public async Task GetExceptionForRequest_ValidJobIdGiven_ShouldReturnJobStatus(string httpClientResponseXml) { var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(httpClientResponseXml, HttpStatusCode.BadRequest)), new XmlSerializationService()); var result = await wpsClient.GetExceptionForRequest(MockUri, new GetResultRequest()); result.Exceptions.Should().HaveCount(3); }
public async Task GetCapabilities_ValidUriGiven_ShouldPass(string httpClientResponseXml) { var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(httpClientResponseXml)), new XmlSerializationService()); var capabilities = await wpsClient.GetCapabilities(MockUri); capabilities.Should().NotBeNull(); }
public async Task DescribeProcess_ValidStringIdentifiersGiven_ShouldReturnTwoProcesses(string httpClientResponseXml) { var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(httpClientResponseXml)), new XmlSerializationService()); var collection = await wpsClient.DescribeProcess(MockUri, "i.gensigset", "i.gensig"); collection.Should().HaveCount(2); }
public async Task AsyncGetDocumentedResult_RawResponseTypeGiven_ShouldThrowInvalidOperationException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <InvalidOperationException>(() => wpsClient.GetDocumentedResult <Data>(MockUri, new ExecuteRequest { ResponseType = ResponseType.Raw })); }
public async Task AsyncGetDocumentedResult_SynchronousExecutionModeGiven_ShouldThrowInvalidOperationException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <InvalidOperationException>(() => wpsClient.GetDocumentedResult <Data>(MockUri, new ExecuteRequest { ExecutionMode = ExecutionMode.Synchronous })); }
public async Task GetResult_ValidJobIdGiven_ShouldReturnJobStatus(string httpClientResponseXml) { const string jobId = "6b3ef43a-ed8d-4063-8c65-e1171687f256"; var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(httpClientResponseXml)), new XmlSerializationService()); var result = await wpsClient.GetResult <LiteralDataValue>(MockUri, jobId); result.JobId.Should().Be(jobId); result.Outputs.Should().HaveCount(1); }
public async Task GetStatus_ValidJobIdGiven_ShouldReturnJobStatus(string httpClientResponseXml) { const string expectedJobId = "FB6DD4B0-A2BB-11E3-A5E2-0800200C9A66"; var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(httpClientResponseXml)), new XmlSerializationService()); var status = await wpsClient.GetJobStatus(MockUri, expectedJobId); status.Should().NotBeNull(); status.JobId.Should().Be(expectedJobId); }
public async Task DescribeProcess_InvalidSummariesGiven_ShouldThrowOwsException(string httpClientResponseXml) { var summaries = new[] { new ProcessSummary { Identifier = "invalid 1" }, new ProcessSummary { Identifier = "invalid 2" } }; var wpsClient = new WpsClient(new HttpClient(GetMockedMessageHandlerForResponse(httpClientResponseXml, HttpStatusCode.BadRequest)), new XmlSerializationService()); await Assert.ThrowsAsync <OwsException>(() => wpsClient.DescribeProcess(MockUri, summaries)); }
private static IContainer CreateContainer() { var container = new Container(); var client = new WpsClient(new HttpClient(), new XmlSerializationService()); // Services container.RegisterInstance <IWpsClient>(client); container.Register <IFileReader, FileReader>(); container.Register <IRequestFactory, RequestFactory>(); container.Register <IContext, ArcgisContext>(); container.Register <IDialogService, DialogService>(); container.Register <IViewModelFactory, ViewModelFactory>(); container.Register <IMapService, MapService>(Reuse.Singleton); container.Register <IAppData, AppData>(); // Repositories container.Register <IServerRepository, ServerRepository>(setup: Setup.With(trackDisposableTransient: true)); container.Register <IResultRepository, ResultsRepository>(setup: Setup.With(trackDisposableTransient: true)); container.Register <ILoggerRepository, FileLoggerRepository>(setup: Setup.With(trackDisposableTransient: true)); // View Models container.Register <AddServerPopupViewModel>(); container.Register <CapabilitiesViewModel>(); container.Register <ResultsViewModel>(); /* * The ResultsViewModel must be initialized before the used does it when opening the results panel. * Not doing so will end up in an empty results panel even after executing a couple of processes. */ var resultsVm = new ResultsViewModel(container.Resolve <IContext>(), container.Resolve <IResultRepository>()); container.RegisterInstance(resultsVm); return(container); }
public async Task DescribeProcess_NullUriGiven_ShouldThrowArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <ArgumentNullException>(() => wpsClient.DescribeProcess(null, string.Empty)); }
public async Task GetCapabilities_NullUriGiven_ShouldThrow_ArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <ArgumentNullException>(() => wpsClient.GetCapabilities(null)); }
public async Task DescribeProcess_EmptyIdentifiersGiven_ShouldThrowArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <InvalidOperationException>(() => wpsClient.DescribeProcess(MockUri, new string[0])); }
public async Task GetResult_NullJobIdGiven_ShouldThrowArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <ArgumentNullException>(() => wpsClient.GetJobStatus(MockUri, null)); }
public async Task AsyncGetDocumentedResult_NullRequestGiven_ShouldThrowArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <ArgumentNullException>(() => wpsClient.AsyncGetDocumentResultAs <Data>(MockUri, null)); }
public async Task GetExceptionForRequest_NullWpsUriGiven_ShouldThrowArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <ArgumentNullException>(() => wpsClient.GetJobStatus(null, string.Empty)); }
public async Task GetDocumentedResult_NullWpsUriGiven_ShouldThrowArgumentNullException() { var wpsClient = new WpsClient(new HttpClient(), new XmlSerializationService()); await Assert.ThrowsAsync <ArgumentNullException>(() => wpsClient.GetDocumentedResult <object>(null, new ExecuteRequest())); }