Пример #1
0
        public async Task <IActionResult> GetRdpFile(string machineTag, CancellationToken token)
        {
            _logger.LogInformation($"Received RDP file request for {machineTag}");
            var latestRecord = await _recordsRepository.GetLatestAsync(machineTag, token).ConfigureAwait(false);

            var stream = await _rdpFileProvider.CreateFileStreamAsync(latestRecord, token).ConfigureAwait(false);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/octet-stream", $"{machineTag}.rdp"));
        }
Пример #2
0
        private async Task FileContent_AsExpected()
        {
            var record = new IpRecord {
                CurrentIP = "127.0.0.1"
            };

            await using var stream = await _provider.CreateFileStreamAsync(record, CancellationToken.None);

            stream.Seek(0, SeekOrigin.Begin);
            using var reader = new StreamReader(stream);
            var firstLine = await reader.ReadLineAsync();

            firstLine.ShouldBe($"full address:s:{record.CurrentIP}:3389");
        }