├── .gitignore
├── README
├── license.txt
└── src
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── ItemTemplates
├── LayoutPage
│ ├── LayoutPage.csproj
│ ├── LayoutPage.spark
│ ├── LayoutPage.vstemplate
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SparkIcon.png
├── ViewPage
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SparkIcon.png
│ ├── ViewPage.csproj
│ ├── ViewPage.spark
│ └── ViewPage.vstemplate
└── ViewPageWithLayout
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SparkIcon.png
│ ├── ViewPageWithLayout.csproj
│ ├── ViewPageWithLayout.spark
│ └── ViewPageWithLayout.vstemplate
├── SparkSense.Tests
├── Compiling
│ └── WhenCompilingIncompleteCode.cs
├── Parsing
│ ├── CachingViewFolderTests.cs
│ ├── ParseContextChunkTests.cs
│ ├── ParseContextNodeTests.cs
│ ├── ParseMultipleNodeTests.cs
│ ├── ParseSingleNodeTests.cs
│ ├── ProjectExplorerTests.cs
│ ├── SparkSyntaxTests.cs
│ ├── ViewExplorerTests.cs
│ └── WhenParsingIncompleteCode.cs
├── Properties
│ └── AssemblyInfo.cs
├── Scenarios
│ ├── Scenario.cs
│ ├── SyntaxCompilationScenario.cs
│ ├── SyntaxParsingScenario.cs
│ ├── TypeCompletionScenario.cs
│ └── TypeResolutionScenario.cs
├── SparkSense.Tests.Views
│ └── Shared
│ │ ├── Application.spark
│ │ ├── _SharedPartial.spark
│ │ └── test.spark
├── SparkSense.Tests.csproj
├── SpecificationExtensions.cs
├── StatementCompletion
│ ├── AttributeCompletionSetTests.cs
│ ├── CompletionSessionTests.cs
│ ├── ElementCompletionSetTests.cs
│ ├── ExpressionCompletionSetTests.cs
│ └── TextViewCreationTests.cs
├── TypeCompletion
│ ├── WhenNavigatingThroughMembers.cs
│ ├── WhenNavigatingThroughNameSpaces.cs
│ └── WhenTriggeringTypeCompletion.cs
├── TypeResolution
│ ├── WhenResolvingInstanceMembers.cs
│ ├── WhenResolvingMethods.cs
│ ├── WhenResolvingStaticMembers.cs
│ ├── WhenResolvingTriggerTypes.cs
│ └── WhenResolvingTypes.cs
└── packages.config
├── SparkSense.gpState
├── SparkSense.ncrunchsolution
├── SparkSense.sln
├── SparkSense
├── ContentType
│ └── SparkFileAndContentTypes.cs
├── Parser
│ ├── CompletionBuilder.cs
│ ├── CompletionBuilderExtensions.cs
│ ├── CompletionGrammar.cs
│ └── CompletionSyntaxProvider.cs
├── Parsing
│ ├── CachingViewFolder.cs
│ ├── Constants.cs
│ ├── IProjectExplorer.cs
│ ├── IViewExplorer.cs
│ ├── ParsingExtensions.cs
│ ├── ProjectExplorer.cs
│ ├── SparkSyntax.cs
│ ├── TypeNavigator.cs
│ └── ViewExplorer.cs
├── Presenter
│ ├── SparkSensePresenter.cs
│ ├── SparkSensePresenterListener.cs
│ ├── SparkSenseView.xaml
│ └── SparkSenseView.xaml.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── Class.png
│ ├── Event.png
│ ├── Field.png
│ ├── Method.png
│ ├── Namespace.png
│ ├── Property.png
│ ├── SparkAttribute.png
│ ├── SparkContentName.png
│ ├── SparkElement.png
│ ├── SparkGlobalVariable.png
│ ├── SparkLocalVariable.png
│ ├── SparkMacro.png
│ ├── SparkMacroParameter.png
│ ├── SparkPartial.png
│ ├── SparkPartialParameter.png
│ └── SparkSenseViewResources.xaml
├── SignatureRecognition
│ ├── SparkSignatureHelpCommand.cs
│ ├── SparkSignatureHelpCommandListener.cs
│ ├── SparkSignatureHelpSource.cs
│ ├── SparkSignatureHelpSourceProvider.cs
│ ├── SparkTagParameter.cs
│ └── SparkTagSignature.cs
├── SparkIcon.png
├── SparkLogo.png
├── SparkSense.csproj
├── SparkServiceProvider.cs
├── StatementCompletion
│ ├── CompletionExtensions.cs
│ ├── CompletionListener.cs
│ ├── CompletionSessionManager.cs
│ ├── CompletionSets
│ │ ├── AttributeCompletionSet.cs
│ │ ├── CompletionSetFactory.cs
│ │ ├── ElementCompletionSet.cs
│ │ └── ExpressionCompletionSet.cs
│ ├── CompletionSource.cs
│ ├── KeyPressInterceptor.cs
│ └── ViewCreationListener.cs
├── license.txt
├── packages.config
└── source.extension.vsixmanifest
└── packages
├── NUnit.2.6.1
├── NUnit.2.6.1.nupkg
├── lib
│ ├── nunit.framework.dll
│ └── nunit.framework.xml
└── license.txt
├── RhinoMocks.3.6.1
├── RhinoMocks.3.6.1.nupkg
└── lib
│ └── net
│ ├── Rhino.Mocks.dll
│ └── Rhino.Mocks.xml
├── Spark.1.7.2.0
├── Spark.1.7.2.0.nupkg
└── lib
│ ├── NET35
│ └── Spark.dll
│ └── NET40
│ └── Spark.dll
├── fasterflect.2.1.0
├── fasterflect.2.1.0.nupkg
└── lib
│ ├── net35
│ ├── Fasterflect.XML
│ └── Fasterflect.dll
│ └── net40
│ ├── Fasterflect.XML
│ └── Fasterflect.dll
└── repositories.config
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore the output folder.
2 | build
3 |
4 | # Ignore all */bin/ and */obj/ folders...
5 | bin/
6 | obj/
7 |
8 | # ...except the root bin folder (used for build tools and etc.).
9 | !/bin/
10 |
11 | # Ignore backup files.
12 | *.orig
13 |
14 | # Ignore all Visual Studio generated files.
15 | *.suo
16 | *.user
17 | *.ncb
18 | _ReSharper.*
19 |
20 | # Ignore all MonoDevelop generated files.
21 | *.userprefs
22 | *.pidb
23 |
24 | # Ignore all Operating System generated files.
25 | Thumbs.db
26 |
27 | # Ignore all Test Suite status files.
28 | TestResult.xml
29 | *.VisualState.xml
30 |
31 | # Ignore some other things, too.
32 | src/Tools/SparkLanguagePackage/*_i.c
33 | src/Tools/SparkLanguagePackage/*_i.h
34 | src/Tools/SparkLanguagePackage/*_p.c
35 | src/Tools/SparkLanguagePackage/PackageLoadKey.h
36 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | SparkSense is a plugin for Visual Studio 2010 that enables various tooling support and productivity features when using Spark as a View Engine for various MVC frameworks including ASP.NET MVC, FubuMVC, Monorail, OpenRasta to name a few. It also works when using Spark as a stand-alone templating engine in VS2010.
2 |
3 | The source code has been moved out of the core Spark library due to key differences in use and applicability and deployment cycles. In addition to providing better visibility for the product, it also takes a dependency on the Visual Studio 2010 SDK which means it cannot be part of the Spark Core primary solution without forcing any developers only interestd in Spark Core to install the SDK. It also also allows those developers who wish to learn about Visual Studio Extensibility without needing to concern themselves with the code base of Spark Core iteself.
--------------------------------------------------------------------------------
/src/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SparkViewEngine/SparkSense/08c46f516a03d7276350c1cf7ceea043673008a6/src/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/src/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
25 |
26 |
27 |
28 |
29 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
30 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config"))
31 | $([System.IO.Path]::Combine($(SolutionDir), "packages"))
32 |
33 |
34 |
35 |
36 | $(SolutionDir).nuget
37 | packages.config
38 | $(SolutionDir)packages
39 |
40 |
41 |
42 |
43 | $(NuGetToolsPath)\nuget.exe
44 | @(PackageSource)
45 |
46 | "$(NuGetExePath)"
47 | mono --runtime=v4.0.30319 $(NuGetExePath)
48 |
49 | $(TargetDir.Trim('\\'))
50 |
51 | -RequireConsent
52 |
53 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -o "$(PackagesDir)"
54 | $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols
55 |
56 |
57 |
58 | RestorePackages;
59 | $(BuildDependsOn);
60 |
61 |
62 |
63 |
64 | $(BuildDependsOn);
65 | BuildPackage;
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
79 |
80 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/src/ItemTemplates/LayoutPage/LayoutPage.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {080A3968-BA97-48B2-AC8C-19AC327E62C6}
8 | Library
9 | Properties
10 | LayoutPage
11 | LayoutPage
12 | v4.0
13 | 512
14 | false
15 | false
16 | false
17 | false
18 | false
19 | false
20 | false
21 | false
22 | false
23 | false
24 |
25 |
26 | true
27 | full
28 | false
29 | bin\Debug\
30 | DEBUG;TRACE
31 | prompt
32 | 4
33 |
34 |
35 | pdbonly
36 | true
37 | bin\Release\
38 | TRACE
39 | prompt
40 | 4
41 |
42 |
43 |
44 | False
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Web\Spark
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
74 |
--------------------------------------------------------------------------------
/src/ItemTemplates/LayoutPage/LayoutPage.spark:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ${ViewBag.Title}
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/ItemTemplates/LayoutPage/LayoutPage.vstemplate:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Spark Layout Page
5 | Layout Page with Spark syntax (spark)
6 | SparkIcon.png
7 | CSharp
8 | 3
9 | true
10 | LayoutPage.spark
11 |
12 |
13 | LayoutPage.spark
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/ItemTemplates/LayoutPage/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LayoutPage")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LayoutPage")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("76e075d5-e0ee-4aaa-8212-f0a5e485ece6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/ItemTemplates/LayoutPage/SparkIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SparkViewEngine/SparkSense/08c46f516a03d7276350c1cf7ceea043673008a6/src/ItemTemplates/LayoutPage/SparkIcon.png
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPage/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ViewPage")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ViewPage")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6d5d7a21-089b-48b4-981a-19f1c03cc05d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPage/SparkIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SparkViewEngine/SparkSense/08c46f516a03d7276350c1cf7ceea043673008a6/src/ItemTemplates/ViewPage/SparkIcon.png
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPage/ViewPage.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {977A1109-A90E-40DE-B976-04A406B9114D}
8 | Library
9 | Properties
10 | ViewPage
11 | ViewPage
12 | v4.0
13 | 512
14 | false
15 | false
16 | false
17 | false
18 | false
19 | false
20 | false
21 | false
22 | false
23 | false
24 |
25 |
26 | true
27 | full
28 | false
29 | bin\Debug\
30 | DEBUG;TRACE
31 | prompt
32 | 4
33 |
34 |
35 | pdbonly
36 | true
37 | bin\Release\
38 | TRACE
39 | prompt
40 | 4
41 |
42 |
43 |
44 | False
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Web\Spark
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
74 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPage/ViewPage.spark:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPage/ViewPage.vstemplate:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Spark View Page
5 | View Page with Spark syntax (spark)
6 | SparkIcon.png
7 | CSharp
8 | 3
9 | true
10 | ViewPage.spark
11 |
12 |
13 | ViewPage.spark
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPageWithLayout/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ViewPageWithLayout")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ViewPageWithLayout")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("92199a7f-d4fa-4162-bbc7-29267b045e18")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPageWithLayout/SparkIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SparkViewEngine/SparkSense/08c46f516a03d7276350c1cf7ceea043673008a6/src/ItemTemplates/ViewPageWithLayout/SparkIcon.png
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPageWithLayout/ViewPageWithLayout.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {24C1E236-C53F-47E8-AA1B-68FE5264C934}
8 | Library
9 | Properties
10 | ViewPageWithLayout
11 | ViewPageWithLayout
12 | v4.0
13 | 512
14 | false
15 | false
16 | false
17 | false
18 | false
19 | false
20 | false
21 | false
22 | false
23 | false
24 |
25 |
26 | true
27 | full
28 | false
29 | bin\Debug\
30 | DEBUG;TRACE
31 | prompt
32 | 4
33 |
34 |
35 | pdbonly
36 | true
37 | bin\Release\
38 | TRACE
39 | prompt
40 | 4
41 |
42 |
43 |
44 | False
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Web\Spark
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
74 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPageWithLayout/ViewPageWithLayout.spark:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/ItemTemplates/ViewPageWithLayout/ViewPageWithLayout.vstemplate:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Spark View Page with Layout
5 | View Page with Layout with Spark syntax (spark)
6 | SparkIcon.png
7 | CSharp
8 | 3
9 | true
10 | ViewPage.spark
11 |
12 |
13 | ViewPageWithLayout.spark
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/SparkSense.Tests/Compiling/WhenCompilingIncompleteCode.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using Spark.Compiler;
3 | using SparkSense.Tests.Scenarios;
4 |
5 | namespace SparkSense.Tests.Compiling
6 | {
7 | public class WhenCompilingIncompleteCode : SyntaxCompilationScenario
8 | {
9 | public WhenCompilingIncompleteCode()
10 | {
11 | GivenSomeContentToCompile(@"${user.
");
12 | WhenCompilingIntoCodeSnippitChunks();
13 | }
14 |
15 | [Test]
16 | public void ShouldContainAnExpressionChunkBetweenTwoLiteralChunks()
17 | {
18 | TheParsedChunks[0]
19 | .ShouldBeOfType()
20 | .Text
21 | .ShouldBe("");
22 |
23 | TheParsedChunks[1]
24 | .ShouldBeOfType()
25 | .Code.ToString()
26 | .ShouldBe("user.");
27 |
28 | TheParsedChunks[2]
29 | .ShouldBeOfType()
30 | .Text
31 | .ShouldBe("
");
32 | }
33 |
34 | [Test]
35 | public void ShouldReturnANumberOfCompiledChunks()
36 | {
37 | TheParsedChunks
38 | .ShouldNotBeNull()
39 | .ShouldHaveCount(3);
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/SparkSense.Tests/Parsing/CachingViewFolderTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 | using SparkSense.Parsing;
4 | using System.IO;
5 |
6 | namespace SparkSense.Tests.Parsing
7 | {
8 | [TestFixture]
9 | public class CachingViewFolderTests
10 | {
11 | private const string ROOT_VIEW_PATH = "SparkSense.Tests.Views";
12 |
13 | [Test]
14 | public void ShouldLoadFromDiskIfPathNotInCache()
15 | {
16 | string contents = String.Empty;
17 | var cache = new CachingViewFolder(ROOT_VIEW_PATH);
18 | var content = cache.GetViewSource("Shared\\Application.spark");
19 |
20 | using (TextReader reader = new StreamReader(content.OpenViewStream()))
21 | contents = reader.ReadToEnd();
22 |
23 | Assert.That(contents.Contains("no header by default"));
24 | }
25 |
26 | [Test]
27 | public void ShouldLoadFromDiskIfPathInCacheWithNullData()
28 | {
29 | string path = "Shared\\Application.spark";
30 | string contents = String.Empty;
31 | var cache = new CachingViewFolder(ROOT_VIEW_PATH);
32 | cache.Add(path);
33 | var content = cache.GetViewSource(path);
34 |
35 | using (TextReader reader = new StreamReader(content.OpenViewStream()))
36 | contents = reader.ReadToEnd();
37 |
38 | Assert.That(contents.Contains("no header by default"));
39 | }
40 |
41 | [Test]
42 | public void ShouldAllowCacheContentToBeReplaced()
43 | {
44 | string path = "Shared\\test.spark";
45 | string contents = String.Empty;
46 | var cache = new CachingViewFolder(ROOT_VIEW_PATH);
47 | cache.Add(path);
48 | string newContent = "This is new content";
49 |
50 | cache.SetViewSource(path, newContent);
51 | var content = cache.GetViewSource(path);
52 | using (TextReader reader = new StreamReader(content.OpenViewStream()))
53 | contents = reader.ReadToEnd();
54 |
55 | Assert.That(contents.Contains(newContent));
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/SparkSense.Tests/Parsing/ParseContextChunkTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using Spark.Compiler;
3 | using SparkSense.Parsing;
4 | using System;
5 |
6 | namespace SparkSense.Tests.Parsing
7 | {
8 | [TestFixture]
9 | public class ParseContextChunkTests
10 | {
11 | [Test]
12 | public void ShouldReturnContentChunkGivenPositionAfterContentElementColon()
13 | {
14 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 14);
15 |
16 | Assert.That(nodeType, Is.EqualTo(typeof(ContentChunk)));
17 | }
18 |
19 | [Test]
20 | public void ShouldReturnContentChunkGivenPositionInsideDoubleQuotes()
21 | {
22 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 20);
23 |
24 | Assert.That(nodeType, Is.EqualTo(typeof(ContentChunk)));
25 | }
26 |
27 | [Test]
28 | public void ShouldReturnContentChunkGivenPositionInsideSingleQuotes()
29 | {
30 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 20);
31 |
32 | Assert.That(nodeType, Is.EqualTo(typeof(ContentChunk)));
33 | }
34 |
35 | [Test]
36 | public void ShouldReturnMacroChunkGivenPositionAfterMacroElementColon()
37 | {
38 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 12);
39 |
40 | Assert.That(nodeType, Is.EqualTo(typeof(MacroChunk)));
41 | }
42 |
43 | [Test]
44 | public void ShouldReturnMacroChunkGivenPositionInsideDoubleQuotes()
45 | {
46 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 18);
47 |
48 | Assert.That(nodeType, Is.EqualTo(typeof(MacroChunk)));
49 | }
50 |
51 | [Test]
52 | public void ShouldReturnMacroChunkGivenPositionInsideSingleQuotes()
53 | {
54 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 18);
55 |
56 | Assert.That(nodeType, Is.EqualTo(typeof(MacroChunk)));
57 | }
58 |
59 | [Test]
60 | public void ShouldReturnRenderChunkGivenPositionAfterRenderElementColon()
61 | {
62 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 13);
63 |
64 | Assert.That(nodeType, Is.EqualTo(typeof(RenderSectionChunk)));
65 | }
66 |
67 | [Test]
68 | public void ShouldReturnRenderChunkGivenPositionInsideDoubleQuotes()
69 | {
70 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 22);
71 |
72 | Assert.That(nodeType, Is.EqualTo(typeof(RenderPartialChunk)));
73 | }
74 |
75 | [Test]
76 | public void ShouldReturnRenderChunkGivenPositionInsideSingleQuotes()
77 | {
78 | Type nodeType = SparkSyntax.ParseContextChunk("", position: 22);
79 |
80 | Assert.That(nodeType, Is.EqualTo(typeof(RenderPartialChunk)));
81 | }
82 |
83 | [Test]
84 | public void ShouldReturnUseChunkGivenPositionAfterUseElementColon()
85 | {
86 | Type nodeType = SparkSyntax.ParseContextChunk("
", position: 10);
87 |
88 | Assert.That(nodeType, Is.EqualTo(typeof(UseContentChunk)));
89 | }
90 |
91 | [Test]
92 | public void ShouldReturnUseChunkGivenPositionInsideDoubleQuotes()
93 | {
94 | Type nodeType = SparkSyntax.ParseContextChunk("