Example #1
0
        public async Task GetFileDetailsAsync_GivenTwoFileDetailsExist_ShouldReturnOneFileDetailsForGivenId()
        {
            //Arrange
            _fileDetailsRepository.GetFileDetailsAsync(Arg.Any <string>()).Returns(args => _fileDetailsList.FirstOrDefault(a => a.Id == args[0].ToString()));

            //Act
            var results = await _storageService.GetFileDetailsAsync(_fileDetails.Id);

            //Assert
            Assert.AreEqual(results.Id, _fileDetails.Id);
            Assert.AreEqual(results.Name, _fileDetails.Name);
            Assert.AreEqual(results.Description, _fileDetails.Description);
            Assert.AreEqual(results.HashId, _fileDetails.HashId);
            Assert.AreEqual(results.Size, _fileDetails.Size);
            Assert.AreEqual(results.StorageId, _fileDetails.StorageId);
        }
Example #2
0
        public async Task <string> DeleteFileAsync(string id)
        {
            var fileDetails = await _fileDetailsRepository.GetFileDetailsAsync(id);

            if (fileDetails == default)
            {
                throw new FilesApiException("No File found for given Id");
            }

            await _fileDetailsRepository.DeleteFileAsync(id);

            var storageId = fileDetails.StorageId;
            var fileName  = fileDetails.Name;

            fileDetails = await _fileDetailsRepository.GetFileDetailsAsync(storageId);

            if (fileDetails == default)
            {
                await _storageRepository.DeleteFileAsync(storageId);
            }
            return(fileName);
        }