コード例 #1
0
        public override Task RemoveDeviceAsync(string deviceId, CancellationToken cancellationToken)
        {
            this.EnsureInstanceNotClosed();

            if (string.IsNullOrWhiteSpace(deviceId))
            {
                throw new ArgumentException(IotHubApiResources.GetString(ApiResources.ParameterCannotBeNullOrWhitespace, "deviceId"));
            }

            // use wildcard etag
            var eTag = new ETagHolder {
                ETag = "*"
            };

            return(this.RemoveDeviceAsync(deviceId, eTag, cancellationToken));
        }
コード例 #2
0
        public override Task CancelJobAsync(string jobId, CancellationToken cancellationToken)
        {
            this.EnsureInstanceNotClosed();

            var errorMappingOverrides = new Dictionary <HttpStatusCode, Func <HttpResponseMessage, Task <Exception> > >();

            errorMappingOverrides.Add(HttpStatusCode.NotFound, responseMessage => Task.FromResult((Exception) new JobNotFoundException(jobId)));

            IETagHolder jobETag = new ETagHolder()
            {
                ETag = jobId
            };

            return(this.httpClientHelper.DeleteAsync(
                       GetJobUri("/{0}".FormatInvariant(jobId)),
                       jobETag,
                       errorMappingOverrides,
                       null,
                       cancellationToken));
        }
コード例 #3
0
        public override Task CancelJobAsync(string jobId, CancellationToken cancellationToken)
        {
            this.EnsureInstanceNotClosed();

            var errorMappingOverrides = new Dictionary<HttpStatusCode, Func<HttpResponseMessage, Task<Exception>>>();
            errorMappingOverrides.Add(HttpStatusCode.NotFound, responseMessage => Task.FromResult((Exception)new JobNotFoundException(jobId)));

            IETagHolder jobETag = new ETagHolder()
            {
                ETag = jobId
            };
            return this.httpClientHelper.DeleteAsync(
                GetJobUri("/{0}".FormatInvariant(jobId)),
                jobETag,
                errorMappingOverrides,
                null,
                cancellationToken);
        }
コード例 #4
0
        public override Task RemoveDeviceAsync(string deviceId, CancellationToken cancellationToken)
        {
            this.EnsureInstanceNotClosed();

            if (string.IsNullOrWhiteSpace(deviceId))
            {
                throw new ArgumentException(IotHubApiResources.GetString(ApiResources.ParameterCannotBeNullOrWhitespace, "deviceId"));
            }

            // use wildcard etag
            var eTag = new ETagHolder { ETag = "*" };
            return this.RemoveDeviceAsync(deviceId, eTag, cancellationToken);
        }
コード例 #5
0
 public async Task DeleteDeviceAsyncTest()
 {
     var restOpMock = new Mock<IHttpClientHelper>();
     var mockETag = new ETagHolder() { ETag = "*" };
     restOpMock.Setup(restOp => restOp.DeleteAsync(It.IsAny<Uri>(), mockETag, It.IsAny<IDictionary<HttpStatusCode, Func<HttpResponseMessage, Task<Exception>>>>(), null, It.IsAny<CancellationToken>())).Returns(Task.FromResult(0));
     var registryManager = new HttpRegistryManager(restOpMock.Object, IotHubName);
     await registryManager.RemoveDeviceAsync(new Device());
     restOpMock.VerifyAll();
 }