/// <inheritdoc /> public Task <SpacesCollection> All() { var spaces = new SpacesCollection(); spaces.Add(_context.Spaces.Select(x => x.Name)); return(Task.FromResult(spaces)); }
public async Task Listing_Spaces_Ignores_Repositories_With_Invalid_Name() { Repository.Init(Path.Combine(_rootPath, ",,,")); SpacesCollection spaces = await _repository.All(); Assert.Empty(spaces.GetSpaceNames()); }
public async Task Listing_Spaces_With_Non_Git_Repository_Ignores_Folder() { await _repository.Add(new Space(new SpaceName("a"))); Directory.CreateDirectory(Path.Combine(_rootPath, "b")); SpacesCollection spaces = await _repository.All(); var names = spaces.GetSpaceNames(); Assert.Single(names); Assert.Equal("a", names.First().ToString()); }
/// <summary> /// Looks up all existing directories that we can possibly use as spaces, contained within our root path. /// </summary> /// <returns>A collection of all existing spaces.</returns> public Task <SpacesCollection> All() { SpacesCollection spaces = new SpacesCollection(); foreach (DirectoryInfo directory in _physicalRootDirectory.GetDirectories()) { if (!Repository.IsValid(directory.FullName)) { continue; } try { var spaceName = new SpaceName(directory.Name); spaces.Add(spaceName); } catch (InvalidSpaceNameException) { // ignore this folder entirely } } return(Task.FromResult(spaces)); }
/// <summary> /// Initializes a new instance of the <see cref="ListSpacesOutput"/> class. /// </summary> /// <param name="existingSpaces">A collection of all existing spaces.</param> public ListSpacesOutput(SpacesCollection existingSpaces) { ExistingSpaces = existingSpaces; }
/// <inheritdoc/> public async Task Execute(ListSpacesInput input) { SpacesCollection spaces = await _spaceService.ListSpaces(); _outputPort.Standard(new ListSpacesOutput(spaces)); }
public async Task Listing_Spaces_When_None_Exist_Returns_Empty_Collection() { SpacesCollection spaces = await _repository.All(); Assert.Empty(spaces.GetSpaceNames()); }