public async Task DownloadModel_ShouldReturnFileDataFromDisk()
        {
            // Arrange
            var runId    = Guid.NewGuid();
            var filePath = mockFileSystem.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".mlops", "model-repository", $"{runId}.zip");

            mockFileSystem.AddFile(filePath, new MockFileData("test"));
            using var memStream = new MemoryStream();

            // Act
            await sut.DownloadModelAsync(runId, memStream);

            memStream.Seek(0, SeekOrigin.Begin);

            // Assert
            Encoding.Default.GetString(memStream.ToArray()).Should().Be("test");
        }
示例#2
0
        public async Task DownloadModel_ThrowsIfFileDoesNotExist()
        {
            var mockFileSystem = new MockFileSystem();
            var folderPath     = mockFileSystem.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".mlops");
            var sut            = new LocalFileModelRepository(mockFileSystem);

            using var memStream = new MemoryStream();

            // Act
            var downloadAction = new Func <Task>(() => sut.DownloadModelAsync(new Guid(), memStream));

            // Assert
            await downloadAction.Should().ThrowExactlyAsync <FileNotFoundException>("Because provided file does not exist on disk");
        }