示例#1
0
        public async Task UseStrictEmptyFile()
        {
            var textView = await VSHost.TypeText(".js", "'");

            textView.IsCompletionOpen().Should().BeTrue();
            await VSHost.TypeString("\t");

            textView.GetText().Should().Be("'use strict';");
            textView.IsCompletionOpen().Should().BeFalse();
        }
示例#2
0
        public async Task BackspaceDismisses()
        {
            var textView = await VSHost.TypeText(".js", "'u");

            textView.IsCompletionOpen().Should().BeTrue();
            await VSHost.TypeString("\b");

            textView.IsCompletionOpen().Should().BeTrue();
            await VSHost.TypeString("\b");

            textView.IsCompletionOpen().Should().BeFalse();
        }
示例#3
0
        public async Task DeletedImports()
        {
            var s2 = (Solution2)VSHost.DTE.Solution;

            s2.Create(TestCaseDirectory, "ImportDeleteTests");
            var template = s2.GetProjectTemplate("EmptyWebApplicationProject40.zip", "CSharp");

            s2.AddFromTemplate(template, Path.Combine(TestCaseDirectory, "WebAppProject2"), "WebAppProject.csproj");

            // To be discovered on save of dependent file
            File.WriteAllText(Path.Combine(TestCaseDirectory, "WebAppProject2", "_mixins.less"), "// Content...");

            AddProjectFile(Path.Combine(TestCaseDirectory, "WebAppProject2", "page.less"), "@import '_mixins';");

            await graph.RescanComplete;

            var deps = await graph.GetRecursiveDependentsAsync(
                Path.Combine(TestCaseDirectory, "WebAppProject2", "_mixins.less")
                );

            deps
            .Select(Path.GetFileName)
            .Should()
            .BeEquivalentTo(new[] { "page.less" });

            var window = VSHost.DTE.ItemOperations.OpenFile(Path.Combine(TestCaseDirectory, "WebAppProject2", "page.less"));

            await VSHost.Dispatcher.NextFrame();    // Text editoro commands must be sent from the UI thread

            var target = (IOleCommandTarget)ProjectHelpers.GetCurrentNativeTextView();

            target.Execute(VSConstants.VSStd97CmdID.SelectAll);
            await VSHost.TypeString("// Import was removed");

            window.Document.Save();

            await graph.RescanComplete;

            deps = await graph.GetRecursiveDependentsAsync(
                Path.Combine(TestCaseDirectory, "WebAppProject2", "_mixins.less")
                );

            deps
            .Select(Path.GetFileName)
            .Should()
            .BeEmpty();
        }
        public async Task SaveDependentFiles()
        {
            var s2 = (Solution2)VSHost.DTE.Solution;

            s2.Create(TestCaseDirectory, "ChainCompilationTests");
            var template = s2.GetProjectTemplate("EmptyWebApplicationProject40.zip", "CSharp");

            s2.AddFromTemplate(template, Path.Combine(TestCaseDirectory, "WebAppProject"), "WebAppProject.csproj");

            // To be discovered on save of dependent file
            var    mixinsPath   = Path.Combine(TestCaseDirectory, "WebAppProject", "_mixins.less");
            string pagePath     = Path.Combine(TestCaseDirectory, "WebAppProject", "page.less");
            string basePath     = Path.Combine(TestCaseDirectory, "WebAppProject", "base.less");
            string otherDepPath = Path.Combine(TestCaseDirectory, "WebAppProject", "otherDep.less");

            File.WriteAllText(mixinsPath, "// Content...");
            AddProjectFile(basePath, "body { font: sans-serif }");
            AddProjectFile(pagePath, "@import 'base';");
            AddProjectFile(otherDepPath, "@import 'base';");

            File.WriteAllText(CssPath(basePath), "");
            File.WriteAllText(CssPath(pagePath), "");
            await Task.Delay(10);   // Give a tiny bit of time for the graph to initialize

            var window = VSHost.DTE.ItemOperations.OpenFile(basePath);
            await VSHost.TypeString("@import url(\"./_mixins.less\");\n");

            window.Document.Save();

            await WaitFor(() => new FileInfo(CssPath(basePath)).Length > 5, "base.less to compile", maxSeconds : 8);
            await WaitFor(() => new FileInfo(CssPath(pagePath)).Length > 5, "page.less to chain compile", maxSeconds : 2);

            File.Exists(CssPath(otherDepPath)).Should().BeFalse("Dependency without .css file should not be compiled");

            window = VSHost.DTE.ItemOperations.OpenFile(mixinsPath);
            await VSHost.TypeString(".MyClass { color: purple; }\n");

            window.Document.Save();

            await WaitFor(() => File.ReadAllText(CssPath(pagePath)).Contains(".MyClass"), "page.less to chain compile", maxSeconds : 2);

            File.Exists(CssPath(mixinsPath)).Should().BeFalse("File without .css file should not be compiled");
        }
示例#5
0
        public async Task DependenciesFromNewFiles()
        {
            var s2 = (Solution2)VSHost.DTE.Solution;

            s2.Create(TestCaseDirectory, "DependencyCreationTests");
            var template = s2.GetProjectTemplate("EmptyWebApplicationProject40.zip", "CSharp");

            s2.AddFromTemplate(template, Path.Combine(TestCaseDirectory, "WebAppProject"), "WebAppProject.csproj");

            // To be discovered on save of dependent file
            File.WriteAllText(Path.Combine(TestCaseDirectory, "WebAppProject", "_mixins.less"), "// Content...");

            AddProjectFile(Path.Combine(TestCaseDirectory, "WebAppProject", "base.less"), "@import url('//google.com/webfonts'); body { font: sans-serif }");

            AddProjectFile(Path.Combine(TestCaseDirectory, "WebAppProject", "page.less"), "@import 'base';");

            await graph.RescanComplete;

            var deps = await graph.GetRecursiveDependentsAsync(
                Path.Combine(TestCaseDirectory, "WebAppProject", "base.less")
                );

            deps
            .Select(Path.GetFileName)
            .Should()
            .BeEquivalentTo(new[] { "page.less" });

            var window = VSHost.DTE.ItemOperations.OpenFile(Path.Combine(TestCaseDirectory, "WebAppProject", "base.less"));
            await VSHost.TypeString("@import url(\"./_mixins\");\n");

            window.Document.Save();

            await graph.RescanComplete;

            deps = await graph.GetRecursiveDependentsAsync(
                Path.Combine(TestCaseDirectory, "WebAppProject", "_mixins.less")
                );

            deps
            .Select(Path.GetFileName)
            .Should()
            .BeEquivalentTo(new[] { "base.less", "page.less" });
        }