Esempio n. 1
0
        private void StubUploadFileAsyncDependency()
        {
            var memoryStream = FakeMemoryStream();

            A.CallTo(() => _formFile.OpenReadStream()).Returns(memoryStream);
            A.CallTo(() => _formFile.Length).Returns(256);
            A.CallTo(() => _formFile.ContentDisposition).Returns("form-data; name=\"UserAvatarFile\"; filename=\"TestFile.txt\"");

            A.CallTo(() => _pathWrapper.GetFileNameWithoutExtension(A <string> ._)).Returns("dummy-file-name");
            A.CallTo(() => _pathWrapper.GetExtension(A <string> ._)).Returns(".txt");
            A.CallTo(() => _pathWrapper.Combine(A <string[]> ._)).Returns("C:\\UnitTestFolder");
            A.CallTo(() => _pathWrapper.Combine(A <string> ._, A <string> ._)).Returns("C:\\UnitTestFolder\\dummy-file-name.txt");

            A.CallTo(() => _environment.WebRootPath).Returns("C:\\");
        }
Esempio n. 2
0
        public virtual string FindFlubuFile()
        {
            if (_searchedForFlubuFile)
            {
                return(_flubuFile);
            }

            _searchedForFlubuFile = true;

            var    currentDirectory = Directory.GetCurrentDirectory();
            var    directories      = currentDirectory.Split(Path.DirectorySeparatorChar);
            string flubuFileDir     = string.Empty;

            foreach (var dir in directories)
            {
                string directory = dir;
                if (dir.EndsWith(":"))
                {
                    directory = $"{dir}{Path.DirectorySeparatorChar}";
                }

                flubuFileDir = _path.Combine(flubuFileDir, directory);
                var flubuFilePath = Path.Combine(flubuFileDir, ".flubu");
                if (File.Exists(flubuFilePath))
                {
                    _flubuFile = flubuFilePath;
                    return(flubuFilePath);
                }
            }

            _flubuFile = null;
            return(_flubuFile);
        }
Esempio n. 3
0
        public string FindFlubuFile()
        {
            var    currentDirectory = Directory.GetCurrentDirectory();
            var    directories      = currentDirectory.Split(Path.DirectorySeparatorChar);
            string flubuFileDir     = string.Empty;

            foreach (var dir in directories)
            {
                string directory = dir;
                if (dir.EndsWith(":"))
                {
                    directory = $"{dir}{Path.DirectorySeparatorChar}";
                }

                string flubuFilePath;
                flubuFileDir  = _path.Combine(flubuFileDir, directory);
                flubuFilePath = Path.Combine(flubuFileDir, ".flubu");
                if (File.Exists(flubuFilePath))
                {
                    return(flubuFilePath);
                }
            }

            return(null);
        }
Esempio n. 4
0
        public string BuildPath(string fileName)
        {
            var fileExtension = _pathWrapper.GetExtension(fileName).Replace(".", "");
            var fullPath      = _pathWrapper.Combine(_appEnvironmentPath, fileExtension, _guidWrapper.NewGuid().ToString() + fileName);

            return(fullPath);
        }
        public void BackupDatabase(IWrapperProvider wrapperProvider, string path)
        {
            IPathWrapper      pathWrapper      = wrapperProvider.GetWrapper <IPathWrapper>();
            IDirectoryWrapper directoryWrapper = wrapperProvider.GetWrapper <IDirectoryWrapper>();
            IFileWrapper      fileWrapper      = wrapperProvider.GetWrapper <IFileWrapper>();
            //copy data.xml to data.xml.bak
            //copy data.xml to data_date.bak - it will override last dayily backup. first run of day will create new one
            string backupFileName = pathWrapper.GetFileNameWithoutExtension(path) + DateTime.Now.ToString("yyyyMMdd");
            string backupPath     = pathWrapper.Combine(
                pathWrapper.GetDirectoryName(path),
                backupFileName);

            backupPath = pathWrapper.ChangeExtension(backupPath, pathWrapper.GetExtension(path));

            bool backupExists = File.Exists(backupPath);

            File.Copy(path, backupPath, true);

            if (!backupExists)
            {
                ManageBackups(path, pathWrapper, directoryWrapper, fileWrapper);
            }
        }
 public LocalPathProviderBuilder WithPathCombine(params string[] pathParts)
 {
     _pathMock.Combine(Arg.Any <string[]>()).Returns(Path.Combine(pathParts));
     return(this);
 }