コード例 #1
0
        public DatasetFetchServiceTest()
        {
            if (!RunningOnWindows)
            {
                // more reporting in each test
                // source of the problem: https://github.com/tathamoddie/System.IO.Abstractions/blob/master/TestingHelpers/MockFileData.cs#L63
                return;
            }

            _fileSystem = new MockFileSystem();
            // if you wonder why the hell next line is sooo long, check this:
            // https://github.com/tathamoddie/System.IO.Abstractions/issues/208
            var appRoot = _fileSystem.Path.Combine(_fileSystem.GetRoot(), "app") + _fileSystem.Path.DirectorySeparatorChar.ToString();

            _fileSystem = new MockFileSystem(
                files: new Dictionary <string, MockFileData>
            {
                { appRoot, new MockDirectoryData() }
            },
                currentDirectory: appRoot);

            var task = new Task(() => { });

            task.Start();
            _downloadService = new Mock <DownloadService>(new object[] { new HttpClient(), (IFileSystem)_fileSystem });
            _downloadService
            .Setup(s => s.DownloadAsync(Url, TemporaryLocation))
            .Callback(() => _fileSystem.File.WriteAllText(TemporaryLocation, DatasetContent))
            .Returns(task);

            _finalDestination = _fileSystem.Path.Combine("blah", DatasetName);
            var placementService = new Mock <DatasetPlacementService>(new object[] { (IFileSystem)_fileSystem });

            placementService
            .Setup(s => s.GetTemporaryDownloadLocation())
            .Returns(TemporaryLocation);
            placementService
            .Setup(s => s.GetDestinationLocation(DatasetName))
            .Returns(_finalDestination);

            _service = new DatasetFetchService(_downloadService.Object, _fileSystem, placementService.Object);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DownloadController"/> class.
 /// </summary>
 /// <param name="fetchService">The fetch service.</param>
 public DownloadController(DatasetFetchService fetchService)
 {
     _fetchService = fetchService;
 }