public void ExportImportDeviceTakingDeviceWithNullEtag()
        {
            // Arrange
            var exportimportDevice = new ExportImportDevice(new Device("device"), ImportMode.Create);

            // nothing to Act on

            // Assert
            Assert.IsTrue(exportimportDevice.ETag == null, "ETag was not set correctly");
        }
        public void ExportImportDeviceTakingDeviceWithEtagWithTrailingDoubleQuotes()
        {
            // Arrange
            var exportimportDevice = new ExportImportDevice(new Device("device") { ETag = "MA==\"\"" }, ImportMode.Create);

            // nothing to Act on

            // Assert
            Assert.IsTrue(exportimportDevice.ETag == "MA==\"", "ETag was not set correctly");
        }
        public override Task<string[]> RemoveDevicesAsync(IEnumerable<Device> devices, bool forceDelete, CancellationToken cancellationToken)
        {
            if (devices == null)
            {
                throw new ArgumentNullException("devices");
            }

            if (!devices.Any())
            {
                throw new ArgumentException("devices");
            }

            var exportImportDeviceList = new List<ExportImportDevice>(devices.Count());
            foreach (var device in devices)
            {
                ValidateDeviceId(device);

                if (string.IsNullOrWhiteSpace(device.ETag) && !forceDelete)
                {
                    throw new ArgumentException(ApiResources.ETagNotSetWhileDeletingDevice);
                }

                var exportImportDevice = new ExportImportDevice(device, forceDelete ? ImportMode.Delete : ImportMode.DeleteIfMatchETag);
                exportImportDeviceList.Add(exportImportDevice);
            }

            return this.BulkDeviceOperationsAsync(exportImportDeviceList, cancellationToken);
        }
        public override Task<string[]> AddDevicesAsync(IEnumerable<Device> devices, CancellationToken cancellationToken)
        {
            if (devices == null)
            {
                throw new ArgumentNullException("devices");
            }

            if (!devices.Any())
            {
                throw new ArgumentException("devices");
            }

            var exportImportDeviceList = new List<ExportImportDevice>(devices.Count());
            foreach (var device in devices)
            {
                ValidateDeviceId(device);

                if (!string.IsNullOrEmpty(device.ETag))
                {
                    throw new ArgumentException(ApiResources.ETagSetWhileRegisteringDevice);
                }

                var exportImportDevice = new ExportImportDevice(device, ImportMode.Create);
                exportImportDeviceList.Add(exportImportDevice);
            }

            return this.BulkDeviceOperationsAsync(exportImportDeviceList, cancellationToken);
        }