Ejemplo n.º 1
0
        public async void SearchFiles_WithCurrentDirectory_MustReturnSpectedChildren(int limit)
        {
            var service = new LocalDriveService();

            var currentDirectory = Helpers.FileSystem.CurrentDirectory;
            var expectedValue    = Directory
                                   .EnumerateFiles(currentDirectory, "*.dll", SearchOption.AllDirectories)
                                   .Where(file => !string.IsNullOrEmpty(file))
                                   .Where(file => File.Exists(file))
                                   .OrderBy(file => file)
                                   .Take(limit)
                                   .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
            })
                                   .ToArray();
            var directoryVM = new DirectoryVM {
                ID = currentDirectory
            };
            var value = await service.SearchFiles(directoryVM, "*.dll", limit);

            Assert.Equal(expectedValue?.Select(x => x.Name)?.ToArray(), value?.Select(x => x.Name)?.ToArray());
            Assert.InRange(value.Length, 0, limit);
        }
Ejemplo n.º 2
0
        public async void SearchFiles_WithNullParameter_MustReturnNull()
        {
            var service = new LocalDriveService();

            DirectoryVM directoryVM = null;
            var         value       = await service.SearchFiles(directoryVM, "*.*");

            Assert.Null(value);
        }
Ejemplo n.º 3
0
        public async void SearchFiles_WithoutConnection_MustReturnNull()
        {
            var connection = ConnectionBuilder.Create().WithCheckConnectionValue(false).Build();
            var service    = new LocalDriveService(connection);

            DirectoryVM directoryVM = null;
            var         value       = await service.SearchFiles(directoryVM, "*.*");

            Assert.Null(value);
        }
Ejemplo n.º 4
0
        public async void SearchFiles_WithInvalidLimit_MustReturnNull(int limit)
        {
            var service = new LocalDriveService();

            var directoryVM = new DirectoryVM {
                ID = Helpers.FileSystem.CurrentDirectory
            };
            var value = await service.SearchFiles(directoryVM, "*.*", limit);

            Assert.Null(value);
        }
Ejemplo n.º 5
0
        public async void SearchFiles_WithInvalidDirectory_MustReturnNull(string directoryID)
        {
            var service = new LocalDriveService();

            var directoryVM = new DirectoryVM {
                ID = directoryID
            };
            var value = await service.SearchFiles(directoryVM, "*.*");

            Assert.Null(value);
        }