public async void GetDetails_WithInvalidParameter_MustReturnNull(string fileID)
        {
            var service = new LocalDriveService();

            var value = await service.GetDetails(fileID);

            Assert.Null(value);
        }
        public async void GetDetails_WithoutConnection_MustReturnNull()
        {
            var connection = ConnectionBuilder.Create().WithCheckConnectionValue(false).Build();
            var service    = new LocalDriveService(connection);

            var fileID = (string)null;
            var value  = await service.GetDetails(fileID);

            Assert.Null(value);
        }
Beispiel #3
0
        public async void Upload_WithValidExistingFile_MustReturnSpectedData()
        {
            using (var sampleClone = new Helpers.SampleClone())
            {
                var service = new LocalDriveService();

                sampleClone.WriteFile();
                var expectedValue = await service.GetDetails(sampleClone.FilePath);

                var value = await service.Upload(sampleClone.FilePath, sampleClone.FileContent);

                Assert.Equal(expectedValue?.SizeInBytes, value?.SizeInBytes);
            }
        }
Beispiel #4
0
        public async void Upload_WithValidNonExistingFile_MustReturnSpectedData()
        {
            using (var sampleClone = new Helpers.SampleClone())
            {
                var service = new LocalDriveService();

                var directoryID = Path.GetDirectoryName(sampleClone.FilePath);
                var fileName    = Path.GetFileName(sampleClone.FilePath);
                var value       = await service.Upload(directoryID, fileName, sampleClone.FileContent);

                var expectedValue = await service.GetDetails($"{directoryID}{Path.DirectorySeparatorChar}{fileName}");

                Assert.Equal(expectedValue?.SizeInBytes, value?.SizeInBytes);
            }
        }
        public async void GetDetails_WithValidFile_MustReturnSpectedData()
        {
            var service = new LocalDriveService();

            var sampleFile    = Helpers.FileSystem.SampleFile;
            var expectedValue = (new string[] { sampleFile })
                                .Select(file => new FileInfo(file))
                                .Where(fileInfo => fileInfo != null)
                                .Select(fileInfo => new FileVM
            {
                ID              = fileInfo.FullName,
                Name            = fileInfo.Name,
                CreatedDateTime = fileInfo.CreationTime,
                SizeInBytes     = fileInfo.Length,
                Path            = fileInfo.DirectoryName,
                ParentID        = fileInfo.DirectoryName
            })
                                .FirstOrDefault();
            var value = await service.GetDetails(sampleFile);

            Assert.Equal(expectedValue?.Name, value?.Name);
        }