private void InitialiseTestEnvironment() { var tempDir = Environment.GetEnvironmentVariable("temp"); if (string.IsNullOrEmpty(tempDir)) { throw new XunitException("Unable to load the temp directory from environment variables."); } _testRootPath = Path.Combine(tempDir, _testDirectoryName); Directory.CreateDirectory(_testRootPath); _testSourcePath = Path.Combine(_testRootPath, "Source"); Directory.CreateDirectory(_testSourcePath); _testDestinationPath = Path.Combine(_testRootPath, "Destination"); Directory.CreateDirectory(_testDestinationPath); _testOptions = new SassFileWatcherOptions { SourcePath = _testSourcePath, DestinationPath = _testDestinationPath, CompileOnStart = false, GenerateSourceMaps = false }; }
public void SassFileWatcher_EmptyFileNameFilters_ThrowsEmptyArrayException() { // Arrange var options = new SassFileWatcherOptions { SourcePath = "test", FileNameFilters = new List <string>() }; var compilerMock = new Mock <ICompiler>(); // Assert Assert.Throws <EmptyArrayException>(() => new SassFileWatcher(options, compilerMock.Object)); }
public void SassFileWatcher_NullSourcePath_ThrowsEmptyStringException() { // Arrange var options = new SassFileWatcherOptions { SourcePath = null }; var compilerMock = new Mock <ICompiler>(); // Assert Assert.Throws <EmptyStringException>(() => new SassFileWatcher(options, compilerMock.Object)); }
public void Compile(List <SassCompilerTestData> filesToCreate, string sourceDirectory, string destinationDirectory) { bool fileExists = false; try { // Arrange foreach (var file in filesToCreate) { WriteScssFile(file.SourceLocation, file.FileContent); } SassFileWatcherOptions options = new SassFileWatcherOptions() { CompileOnStart = false, DestinationPath = destinationDirectory, SourcePath = sourceDirectory }; ICompiler compiler = new SassCompiler(options); // Act compiler.Compile(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); }
public void StartFileWatcher_CompileOnStartTrue_CallsICompilerCompileMethod() { // Arrange InitialiseTestEnvironment(); var compilerMock = new Mock <ICompiler>(); compilerMock.Setup(o => o.Compile(It.IsAny <string>())); var options = new SassFileWatcherOptions { SourcePath = _testOptions.SourcePath, CompileOnStart = true }; var sassWatcher = new SassFileWatcher(options, compilerMock.Object); // Act sassWatcher.StartFileWatcher(); sassWatcher.StopFileWatcher(); CleanUpTestEnvironment(); // Assert compilerMock.Verify(o => o.Compile(It.IsAny <string>()), Times.Once); }
public SassCompiler(SassFileWatcherOptions options) { _options = options; }