Пример #1
0
        public async void DownloadTwinJsonTest()
        {
            var deviceId    = _fixture.Create <string>();
            var deviceModel = _fixture.Create <DeviceModel>();

            deviceModel.Twin = _fixture.Create <Microsoft.Azure.Devices.Shared.Twin>();

            _deviceLogicMock.Setup(mock => mock.GetDeviceAsync(deviceId)).ReturnsAsync(deviceModel);
            var result = await _deviceController.DownloadTwinJson(deviceId);

            Assert.Equal(((FileContentResult)result).FileContents, System.Text.UTF8Encoding.UTF8.GetBytes(deviceModel.Twin.ToJson()));

            _deviceLogicMock.Setup(mock => mock.GetDeviceAsync(deviceId)).ReturnsAsync(null);
            await Assert.ThrowsAsync <DeviceAdmin.Infrastructure.Exceptions.DeviceNotRegisteredException>(() => _deviceController.DownloadTwinJson(deviceId));

            deviceId = null;
            await Assert.ThrowsAsync <ArgumentException>(() => _deviceController.DownloadTwinJson(deviceId));
        }