Пример #1
0
        public void StartFileWatchers()
        {
            var sassFileWatchersOptions = _options.Value.TaskFileWatchers;

            foreach (var sassFileWatcherOptions in sassFileWatchersOptions)
            {
                ITask sassCompiler    = new SassCompilerTask(sassFileWatcherOptions);
                var   sassFileWatcher = new TaskFileWatcher(sassFileWatcherOptions, sassCompiler);
                sassFileWatcher.StartFileWatcher();
                _sassFileWatchers.Add(sassFileWatcher);
            }
        }
Пример #2
0
        public void Compile(List <SassCompilerTaskTestData> filesToCreate, string sourceDirectory, string destinationDirectory)
        {
            bool fileExists = false;

            try
            {
                // Arrange
                foreach (var file in filesToCreate)
                {
                    WriteScssFile(file.SourceLocation, file.FileContent);
                }
                FileWatcherOptions options = new FileWatcherOptions()
                {
                    CompileOnStart = false, DestinationPath = destinationDirectory, SourcePath = sourceDirectory
                };
                ITask compiler = new SassCompilerTask(options);

                // Act
                compiler.Run(sourceDirectory);

                foreach (var file in filesToCreate)
                {
                    if (compiler.IsExcluded(Path.GetFileName(file.SourceLocation)))
                    {
                        fileExists = !File.Exists(file.DestinationLocation);
                    }
                    else
                    {
                        fileExists = File.Exists(file.DestinationLocation);
                    }

                    if (fileExists == false)
                    {
                        break;
                    }
                }
            }
            finally
            {
                CleanUpTestEnvironment();
            }
            // Assert
            Assert.True(fileExists);
        }