public async void GetFiles_WithCurrentDirectory_MustReturnSpectedChildren() { var service = new LocalDriveService(); var currentDirectory = Helpers.FileSystem.CurrentDirectory; var expectedValue = Directory .EnumerateFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly) .Where(file => !string.IsNullOrEmpty(file)) .Where(file => File.Exists(file)) .OrderBy(file => file) .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.GetFiles(directoryVM); Assert.NotNull(value); Assert.NotEmpty(value); Assert.Equal( expectedValue.Where(x => x.Name.EndsWith("dll")).Select(x => x.ID).ToArray(), value.Where(x => x.Name.EndsWith("dll")).Select(x => x.ID).ToArray()); }
public async void GetFiles_WithNullParameter_MustReturnNull() { var service = new LocalDriveService(); DirectoryVM directoryVM = null; var value = await service.GetFiles(directoryVM); Assert.Null(value); }
public async void GetFiles_WithoutConnection_MustReturnNull() { var connection = ConnectionBuilder.Create().WithCheckConnectionValue(false).Build(); var service = new LocalDriveService(connection); DirectoryVM directoryVM = null; var value = await service.GetFiles(directoryVM); Assert.Null(value); }
public async void GetFiles_WithInvalidParameter_MustReturnNull(string directoryID) { var service = new LocalDriveService(); var directoryVM = new DirectoryVM { ID = directoryID }; var value = await service.GetFiles(directoryVM); Assert.Null(value); }