public async Task TestDeleteWithQueryAndOptions()
        {
            var port = _server.Ports.First();
            var initServiceOptions = new InitServiceOptions(port);

            _sut = new ServiceProxy(new Dictionary <string, string>(), "localhost", initServiceOptions);

            _server
            .Given(Request.Create().WithPath("/foo").WithParam("bar", "baz").UsingDelete())
            .RespondWith(
                Response.Create()
                .WithStatusCode(SUCCESS_STATUS_CODE)
                .WithBody(SUCCESS_RESPONSE_BODY)
                );

            var headers = new Dictionary <string, string> {
                { "foo", "bar" }
            };
            var response = await _sut.Delete("foo", "bar=baz", "", new ServiceOptions(port, Protocol.Http, headers));

            var statusCode   = (int)response.StatusCode;
            var responseBody = await response.Content.ReadAsStringAsync();

            Check.That(response.RequestMessage.Headers.GetValues("foo").First()).IsEqualTo("bar");
            Check.That(statusCode).IsEqualTo(SUCCESS_STATUS_CODE);
            Check.That(responseBody).IsEqualTo(SUCCESS_RESPONSE_BODY);
        }
        public IActionResult Delete(string id)
        {
            ServiceProxy proxy = new ServiceProxy();

            proxy.Delete(id);
            TempData["Message"] = "Customer deleted successfully!";
            return(RedirectToAction("Index"));
        }
Example #3
0
        public void Delete_ValidParametersSupplied_SendRequestSendMethodIsCalled()
        {
            var proxy = new ServiceProxy(_cloudId, _accessKey, _secretKey, _apiHost, new ServiceProxyUtility(), _serviceRequest);

            proxy.Delete("videos.json", new Dictionary <string, string>
            {
                { "some_parameter", "some_value" },
                { "another_parameter", "another_value" }
            });

            _serviceRequest.AssertWasCalled(req => req.Send());
        }
        public async Task TestDelete()
        {
            var initServiceOptions = new InitServiceOptions(_server.Ports.First());

            _sut = new ServiceProxy(new Dictionary <string, string>(), "localhost", initServiceOptions);

            _server
            .Given(Request.Create().WithPath("/foo").UsingDelete())
            .RespondWith(
                Response.Create()
                .WithStatusCode(SUCCESS_STATUS_CODE)
                .WithBody(SUCCESS_RESPONSE_BODY)
                );

            var response = await _sut.Delete("foo", "foo=bar");

            var statusCode   = (int)response.StatusCode;
            var responseBody = await response.Content.ReadAsStringAsync();

            Check.That(statusCode).IsEqualTo(SUCCESS_STATUS_CODE);
            Check.That(responseBody).IsEqualTo(SUCCESS_RESPONSE_BODY);
        }
 public void Delete(string entityLogicalName, Guid id)
 {
     ServiceProxy.Delete(entityLogicalName, id);
 }