Nfield.Services.Implementation.NfieldAddressesService.DeleteAsync C# (CSharp) Method

DeleteAsync() public method

public DeleteAsync ( string surveyId, string samplingPointId, string addressId ) : System.Threading.Tasks.Task
surveyId string
samplingPointId string
addressId string
return System.Threading.Tasks.Task
        public Task DeleteAsync(string surveyId, string samplingPointId, string addressId)
        {
            CheckSurveyIdAndSamplingPointId(surveyId, samplingPointId);
            if (addressId == null)
                throw new ArgumentNullException("addressId");
            if (addressId.Trim().Length == 0)
                throw new ArgumentException("addressId cannot be empty");

            var uri = AddressesApi(surveyId, samplingPointId, addressId).AbsoluteUri;

            return Client.DeleteAsync(uri).FlattenExceptions();
        }

Usage Example

        public void TestDeleteAsync_ServerAcceptsDelete_ReturnsNoError()
        {
            const string surveyId = "SurveyId";
            const string samplingPointId = "SamplingPointId";
            const string addressId = "AddressId";

            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);

            mockedHttpClient.Setup(client => client.DeleteAsync(It.IsAny<string>()))
                                    .Returns(CreateTask(HttpStatusCode.NoContent));

            var target = new NfieldAddressesService();
            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            target.DeleteAsync(surveyId, samplingPointId, addressId).Wait();
        }