Ejemplo n.º 1
0
        public bool Process(AnalyserResult analyserResult, string line, int lineIndex)
        {
            if (!line.TrimStart().StartsWith("//#ass", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            int dllIndex = line.IndexOf(" ", StringComparison.Ordinal);

            if (dllIndex < 0)
            {
                return(true);
            }

            string dll       = line.Substring(dllIndex);
            string pathToDll = Path.GetFullPath(dll.Trim());
            string extension = _pathWrapper.GetExtension(pathToDll);

            if (!extension.Equals(".dll", StringComparison.OrdinalIgnoreCase))
            {
                if (!extension.Equals(".exe", StringComparison.OrdinalIgnoreCase))
                {
                    throw new ScriptException($"File doesn't have dll extension. {pathToDll}");
                }
            }

            if (!_file.Exists(pathToDll))
            {
                throw new ScriptException($"Assembly not found at location: {pathToDll}");
            }

            analyserResult.References.Add(pathToDll);
            return(true);
        }
Ejemplo n.º 2
0
        public string BuildPath(string fileName)
        {
            var fileExtension = _pathWrapper.GetExtension(fileName).Replace(".", "");
            var fullPath      = _pathWrapper.Combine(_appEnvironmentPath, fileExtension, _guidWrapper.NewGuid().ToString() + fileName);

            return(fullPath);
        }
Ejemplo n.º 3
0
        private string TakeExplicitBuildScriptName(CommandArguments args)
        {
            if (_file.Exists(args.Script))
            {
                var extension = _path.GetExtension(args.Script);
                if (string.IsNullOrEmpty(extension) || !extension.Equals(".cs"))
                {
                    throw new BuildScriptLocatorException($"The file specified ('{args.Script}') is not a csharp source code (.cs) file. See getting started on https://github.com/flubu-core/flubu.core/wiki");
                }

                return(args.Script);
            }

            throw new BuildScriptLocatorException($"The build script file specified ('{args.Script}') does not exist.");
        }
Ejemplo n.º 4
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:\\");
        }
        public bool Process(ScriptAnalyzerResult analyzerResult, string line, int lineIndex)
        {
            if (!line.StartsWith("//#ass", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            int dllIndex = line.IndexOf(" ", StringComparison.Ordinal);

            if (dllIndex < 0)
            {
                return(true);
            }

            string dll       = line.Substring(dllIndex);
            string pathToDll = Path.GetFullPath(dll.Trim());
            string extension = _pathWrapper.GetExtension(pathToDll);

            if (!extension.Equals(".dll", StringComparison.OrdinalIgnoreCase))
            {
                if (!extension.Equals(".exe", StringComparison.OrdinalIgnoreCase))
                {
                    throw new ScriptException($"File doesn't have dll extension. {pathToDll}");
                }
            }

            if (!_file.Exists(pathToDll))
            {
                throw new ScriptException($"Assembly not found at location: {pathToDll}");
            }

            _log.LogInformation("#ass directives are obsolete and will be removed in future versions. Use 'Assembly' attribute instead on build script class.");

            analyzerResult.AssemblyReferences.Add(new AssemblyInfo
            {
                Name          = pathToDll,
                VersionStatus = VersionStatus.NotAvailable,
                FullPath      = pathToDll
            });

            return(true);
        }
        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);
            }
        }
Ejemplo n.º 7
0
        private void ProcessAssembly(ScriptAnalyzerResult analyzerResult, string pathToDll)
        {
            string extension = _pathWrapper.GetExtension(pathToDll);

            if (!extension.Equals(".dll", StringComparison.OrdinalIgnoreCase))
            {
                if (!extension.Equals(".exe", StringComparison.OrdinalIgnoreCase))
                {
                    throw new ScriptException($"File doesn't have dll extension. {pathToDll}");
                }
            }

            if (!_file.Exists(pathToDll))
            {
                throw new ScriptException($"Assembly not found at location: {pathToDll}");
            }

            analyzerResult.AssemblyReferences.Add(new AssemblyInfo
            {
                Name          = pathToDll,
                VersionStatus = VersionStatus.NotAvailable,
                FullPath      = pathToDll
            });
        }
 public LocalPathProviderBuilder WithGetExtension(string fileName)
 {
     _pathMock.GetExtension("test").Returns(Path.GetExtension(fileName));
     return(this);
 }