예제 #1
0
        public async Task Single_Space_Can_Be_Fetched()
        {
            await _repository.Add(new Space(new SpaceName("single")));

            Space space = (Space)await _repository.Get(new SpaceName("single"));

            Assert.NotNull(space);
            Assert.Equal("single", space.Name.ToString());
            Assert.Equal(
                new DirectoryInfo(Path.Combine(_rootPath, "single")).FullName,
                space.BaseDirectory?.FullName);
        }
예제 #2
0
        /// <summary>
        /// Retrieves the space with the given name.
        /// </summary>
        /// <remarks>The original space name passed to this method, and the name of the returned space, may differ on case-insensitive file systems.</remarks>
        /// <param name="name">The name of the space to retrieve.</param>
        /// <returns>The space that was retrieved.</returns>
        /// <exception cref="SpaceNotFoundException">Thrown when the directory does not exist or is not a valid git repository.</exception>
        public Task <ISpace> Get(SpaceName name)
        {
            #region Windows: Try to retrieve the name with correct case sensitivity
            var    fsInfo     = _physicalRootDirectory.GetFileSystemInfos(name.ToString());
            string folderName = name.ToString();
            if (fsInfo.Length == 1)
            {
                folderName = fsInfo[0].Name;
            }
            #endregion

            DirectoryInfo spaceDirectory = new DirectoryInfo(Path.Combine(_physicalRootDirectory.FullName, folderName));
            if (!spaceDirectory.Exists || !Repository.IsValid(spaceDirectory.FullName))
            {
                throw new SpaceNotFoundException($"Space '{name}' does not exist.");
            }

            var space = new Space(new SpaceName(spaceDirectory.Name))
            {
                BaseDirectory = spaceDirectory,
            };

            return(Task.FromResult <ISpace>(space));
        }