Skip to content
Permalink
Browse files

Initial tech-demo

  • Loading branch information...
Tomáš Herceg
Tomáš Herceg committed Nov 5, 2014
1 parent 77b3b6f commit cab1c3b8b8cb6469ae0fafcb971170b1a0383542
Showing with 45,462 additions and 0 deletions.
  1. +63 −0 .gitattributes
  2. +72 −0 src/Redwood.Framework.Tests/Binding/CommandResolverTests.cs
  3. +59 −0 src/Redwood.Framework.Tests/Binding/ExpressionEvaluatorTests.cs
  4. +161 −0 src/Redwood.Framework.Tests/Parser/RwHtml/RwHtmlParserTests.cs
  5. +98 −0 src/Redwood.Framework.Tests/Parser/RwHtml/RwHtmlTokenizerDirectivesTests.cs
  6. +241 −0 src/Redwood.Framework.Tests/Parser/RwHtml/RwHtmlTokenizerElementsTests.cs
  7. +41 −0 src/Redwood.Framework.Tests/Parser/RwHtml/RwHtmlTokenizerTestsBase.cs
  8. +73 −0 src/Redwood.Framework.Tests/Parser/Translation/ExpressionTranslatorTests.cs
  9. +36 −0 src/Redwood.Framework.Tests/Properties/AssemblyInfo.cs
  10. +101 −0 src/Redwood.Framework.Tests/Redwood.Framework.Tests.csproj
  11. +136 −0 src/Redwood.Framework.Tests/Routing/RedwoodRouteTests.cs
  12. +123 −0 src/Redwood.Framework.Tests/Runtime/DefaultViewCompilerTests.cs
  13. +44 −0 src/Redwood.Framework/Binding/BindingExpression.cs
  14. +40 −0 src/Redwood.Framework/Binding/CommandBindingExpression.cs
  15. +98 −0 src/Redwood.Framework/Binding/CommandResolver.cs
  16. +27 −0 src/Redwood.Framework/Binding/ControlStateBindingExpression.cs
  17. +176 −0 src/Redwood.Framework/Binding/ExpressionEvaluationVisitor.cs
  18. +44 −0 src/Redwood.Framework/Binding/ExpressionEvaluator.cs
  19. +54 −0 src/Redwood.Framework/Binding/ValueBindingExpression.cs
  20. +37 −0 src/Redwood.Framework/Configuration/RedwoodConfiguration.cs
  21. +24 −0 src/Redwood.Framework/Configuration/RedwoodControlConfiguration.cs
  22. +35 −0 src/Redwood.Framework/Configuration/RedwoodMarkupConfiguration.cs
  23. +46 −0 src/Redwood.Framework/Controls/Button.cs
  24. +10 −0 src/Redwood.Framework/Controls/DataItemContainer.cs
  25. +19 −0 src/Redwood.Framework/Controls/DelegateTemplate.cs
  26. +88 −0 src/Redwood.Framework/Controls/HtmlGenericControl.cs
  27. +136 −0 src/Redwood.Framework/Controls/HtmlWriter.cs
  28. +16 −0 src/Redwood.Framework/Controls/IControlWithHtmlAttributes.cs
  29. +46 −0 src/Redwood.Framework/Controls/IHtmlWriter.cs
  30. +9 −0 src/Redwood.Framework/Controls/ITemplate.cs
  31. +41 −0 src/Redwood.Framework/Controls/IntegrationScripts.cs
  32. +49 −0 src/Redwood.Framework/Controls/LinkButton.cs
  33. +80 −0 src/Redwood.Framework/Controls/Literal.cs
  34. +14 −0 src/Redwood.Framework/Controls/MappingMode.cs
  35. +35 −0 src/Redwood.Framework/Controls/MarkupOptionsAttribute.cs
  36. +6 −0 src/Redwood.Framework/Controls/Placeholder.cs
  37. +109 −0 src/Redwood.Framework/Controls/RedwoodBindableControl.cs
  38. +88 −0 src/Redwood.Framework/Controls/RedwoodControl.cs
  39. +178 −0 src/Redwood.Framework/Controls/RedwoodControlCollection.cs
  40. +100 −0 src/Redwood.Framework/Controls/RedwoodProperty.cs
  41. +69 −0 src/Redwood.Framework/Controls/RedwoodStatefulControl.cs
  42. +20 −0 src/Redwood.Framework/Controls/RedwoodView.cs
  43. +25 −0 src/Redwood.Framework/Controls/RenderContext.cs
  44. +87 −0 src/Redwood.Framework/Controls/Repeater.cs
  45. +38 −0 src/Redwood.Framework/Controls/TextBox.cs
  46. +83 −0 src/Redwood.Framework/Hosting/DefaultControlBuilderFactory.cs
  47. +40 −0 src/Redwood.Framework/Hosting/DefaultMarkupFileLoader.cs
  48. +41 −0 src/Redwood.Framework/Hosting/DefaultOutputRenderer.cs
  49. +32 −0 src/Redwood.Framework/Hosting/DefaultViewModelLocator.cs
  50. +634 −0 src/Redwood.Framework/Hosting/ErrorPageTemplate.cs
  51. +185 −0 src/Redwood.Framework/Hosting/ErrorPageTemplate.tt
  52. +56 −0 src/Redwood.Framework/Hosting/FileReader.cs
  53. +14 −0 src/Redwood.Framework/Hosting/IControlBuilderFactory.cs
  54. +13 −0 src/Redwood.Framework/Hosting/IMarkupFileLoader.cs
  55. +16 −0 src/Redwood.Framework/Hosting/IOutputRenderer.cs
  56. +15 −0 src/Redwood.Framework/Hosting/IRedwoodPresenter.cs
  57. +14 −0 src/Redwood.Framework/Hosting/IViewModelLoader.cs
  58. +16 −0 src/Redwood.Framework/Hosting/IViewModelSerializer.cs
  59. +50 −0 src/Redwood.Framework/Hosting/MarkupFile.cs
  60. +24 −0 src/Redwood.Framework/Hosting/RedwoodHttpException.cs
  61. +54 −0 src/Redwood.Framework/Hosting/RedwoodMiddleware.cs
  62. +175 −0 src/Redwood.Framework/Hosting/RedwoodPresenter.cs
  63. +25 −0 src/Redwood.Framework/Hosting/RedwoodRequestContext.cs
  64. +45 −0 src/Redwood.Framework/Hosting/ViewModelSerializer.cs
  65. +41 −0 src/Redwood.Framework/KnockoutHelper.cs
  66. +24 −0 src/Redwood.Framework/Parser/IReader.cs
  67. +40 −0 src/Redwood.Framework/Parser/ParserException.cs
  68. +17 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlAttributeNode.cs
  69. +13 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlBindingNode.cs
  70. +15 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlDirectiveNode.cs
  71. +33 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlElementNode.cs
  72. +13 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlLiteralNode.cs
  73. +29 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlNode.cs
  74. +17 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlNodeWithContent.cs
  75. +350 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlParser.cs
  76. +20 −0 src/Redwood.Framework/Parser/RwHtml/Parser/RwHtmlRootNode.cs
  77. +10 −0 src/Redwood.Framework/Parser/RwHtml/Tokenizer/RwHtmlToken.cs
  78. +24 −0 src/Redwood.Framework/Parser/RwHtml/Tokenizer/RwHtmlTokenType.cs
  79. +399 −0 src/Redwood.Framework/Parser/RwHtml/Tokenizer/RwHtmlTokenizer.cs
  80. +64 −0 src/Redwood.Framework/Parser/StringReader.cs
  81. +28 −0 src/Redwood.Framework/Parser/TokenBase.cs
  82. +261 −0 src/Redwood.Framework/Parser/TokenizerBase.cs
  83. +53 −0 src/Redwood.Framework/Parser/Translation/ExpressionTranslator.cs
  84. +161 −0 src/Redwood.Framework/Parser/Translation/ExpressionTranslatorVisitor.cs
  85. +38 −0 src/Redwood.Framework/Properties/AssemblyInfo.cs
  86. +211 −0 src/Redwood.Framework/Redwood.Framework.csproj
  87. +81 −0 src/Redwood.Framework/Resources/Controls.Designer.cs
  88. +107 −0 src/Redwood.Framework/Resources/Controls.resx
  89. +225 −0 src/Redwood.Framework/Resources/Parser.RwHtml.Designer.cs
  90. +174 −0 src/Redwood.Framework/Resources/Parser.RwHtml.resx
  91. +145 −0 src/Redwood.Framework/Routing/RedwoodRoute.cs
  92. +121 −0 src/Redwood.Framework/Routing/RedwoodRouteComponent.cs
  93. +85 −0 src/Redwood.Framework/Routing/RedwoodRouteTable.cs
  94. +161 −0 src/Redwood.Framework/Routing/RouteBase.cs
  95. +29 −0 src/Redwood.Framework/Runtime/ControlResolverMetadata.cs
  96. +18 −0 src/Redwood.Framework/Runtime/ControlResolverPropertyMetadata.cs
  97. +148 −0 src/Redwood.Framework/Runtime/DefaultControlResolver.cs
  98. +318 −0 src/Redwood.Framework/Runtime/DefaultViewCompiler.cs
  99. +313 −0 src/Redwood.Framework/Runtime/DefaultViewCompilerCodeEmitter.cs
  100. +22 −0 src/Redwood.Framework/Runtime/EmitterMethodInfo.cs
  101. +14 −0 src/Redwood.Framework/Runtime/IControlBuilder.cs
  102. +20 −0 src/Redwood.Framework/Runtime/IControlResolver.cs
  103. +21 −0 src/Redwood.Framework/Runtime/IViewCompiler.cs
  104. +52 −0 src/Redwood.Framework/Runtime/RoslynExtensionMethods.cs
  105. +28 −0 src/Redwood.Framework/Utils/ReflectionUtils.cs
  106. +28 −0 src/Redwood.Framework/ViewModel/BindAttribute.cs
  107. +25 −0 src/Redwood.Framework/ViewModel/ClientCommandAttribute.cs
  108. +15 −0 src/Redwood.Framework/ViewModel/CollectionOptionsAttribute.cs
  109. +13 −0 src/Redwood.Framework/ViewModel/Direction.cs
  110. +21 −0 src/Redwood.Framework/ViewModel/IRedwoodViewModel.cs
  111. +17 −0 src/Redwood.Framework/ViewModel/IViewModelSerializationHandler.cs
  112. +24 −0 src/Redwood.Framework/ViewModel/KeyPropertyAttribute.cs
  113. +13 −0 src/Redwood.Framework/ViewModel/PropertyOptionsAttribute.cs
  114. +31 −0 src/Redwood.Framework/ViewModel/RedwoodViewModelBase.cs
  115. +10 −0 src/Redwood.Framework/packages.config
  116. +68 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/alerts.less
  117. +55 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/badges.less
  118. +6,314 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/bootstrap.css
  119. +73 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/bootstrap.css.map
  120. +50 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/bootstrap.less
  121. +4 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/bootstrap.min.css
  122. +26 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/breadcrumbs.less
  123. +247 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/button-groups.less
  124. +160 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/buttons.less
  125. +267 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/carousel.less
  126. +33 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/close.less
  127. +69 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/code.less
  128. +34 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/component-animations.less
  129. +213 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/dropdowns.less
  130. +559 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/forms.less
  131. +234 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/glyphicons.less
  132. +84 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/grid.less
  133. +166 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/input-groups.less
  134. +48 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/jumbotron.less
  135. +64 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/labels.less
  136. +132 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/list-group.less
  137. +47 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/media.less
  138. +39 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins.less
  139. +14 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/alerts.less
  140. +8 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/background-variant.less
  141. +18 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/border-radius.less
  142. +52 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/buttons.less
  143. +7 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/center-block.less
  144. +22 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/clearfix.less
  145. +85 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/forms.less
  146. +59 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/gradients.less
  147. +91 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/grid-framework.less
  148. +122 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/grid.less
  149. +21 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/hide-text.less
  150. +33 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/image.less
  151. +12 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/labels.less
  152. +29 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/list-group.less
  153. +10 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/nav-divider.less
  154. +9 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/nav-vertical-align.less
  155. +8 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/opacity.less
  156. +23 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/pagination.less
  157. +24 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/panels.less
  158. +10 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/progress-bar.less
  159. +8 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/reset-filter.less
  160. +6 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/resize.less
  161. +15 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/responsive-visibility.less
  162. +10 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/size.less
  163. +9 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/tab-focus.less
  164. +28 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/table-row.less
  165. +8 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/text-emphasis.less
  166. +8 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/text-overflow.less
  167. +227 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/mixins/vendor-prefixes.less
  168. +149 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/modals.less
  169. +659 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/navbar.less
  170. +244 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/navs.less
  171. +427 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/normalize.less
  172. +54 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/pager.less
  173. +88 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/pagination.less
  174. +261 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/panels.less
  175. +134 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/popovers.less
  176. +107 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/print.less
  177. +87 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/progress-bars.less
  178. +35 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/responsive-embed.less
  179. +194 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/responsive-utilities.less
  180. +150 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/scaffolding.less
  181. +234 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/tables.less
  182. +260 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/theme.less
  183. +36 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/thumbnails.less
  184. +95 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/tooltip.less
  185. +302 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/type.less
  186. +56 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/utilities.less
  187. +856 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/variables.less
  188. +29 −0 src/Redwood.Samples.BasicSamples/Content/bootstrap/wells.less
  189. BIN src/Redwood.Samples.BasicSamples/Content/fonts/glyphicons-halflings-regular.eot
  190. +229 −0 src/Redwood.Samples.BasicSamples/Content/fonts/glyphicons-halflings-regular.svg
  191. BIN src/Redwood.Samples.BasicSamples/Content/fonts/glyphicons-halflings-regular.ttf
  192. BIN src/Redwood.Samples.BasicSamples/Content/fonts/glyphicons-halflings-regular.woff
  193. +35 −0 src/Redwood.Samples.BasicSamples/Properties/AssemblyInfo.cs
  194. +233 −0 src/Redwood.Samples.BasicSamples/Redwood.Samples.BasicSamples.csproj
  195. +57 −0 src/Redwood.Samples.BasicSamples/Scripts/Redwood.js
  196. +1 −0 src/Redwood.Samples.BasicSamples/Scripts/Redwood.js.map
  197. +54 −0 src/Redwood.Samples.BasicSamples/Scripts/Redwood.ts
  198. +2,276 −0 src/Redwood.Samples.BasicSamples/Scripts/bootstrap.js
  199. +7 −0 src/Redwood.Samples.BasicSamples/Scripts/bootstrap.min.js
  200. +2,617 −0 src/Redwood.Samples.BasicSamples/Scripts/jquery-1.9.0.intellisense.js
  201. +9,555 −0 src/Redwood.Samples.BasicSamples/Scripts/jquery-1.9.0.js
  202. +4 −0 src/Redwood.Samples.BasicSamples/Scripts/jquery-1.9.0.min.js
  203. +1 −0 src/Redwood.Samples.BasicSamples/Scripts/jquery-1.9.0.min.map
  204. +5,299 −0 src/Redwood.Samples.BasicSamples/Scripts/knockout-3.2.0.debug.js
  205. +111 −0 src/Redwood.Samples.BasicSamples/Scripts/knockout-3.2.0.js
  206. +796 −0 src/Redwood.Samples.BasicSamples/Scripts/knockout.mapping-latest.debug.js
  207. +21 −0 src/Redwood.Samples.BasicSamples/Scripts/knockout.mapping-latest.js
  208. +53 −0 src/Redwood.Samples.BasicSamples/Scripts/typings/knockout.mapping/knockout.mapping.d.ts
  209. +648 −0 src/Redwood.Samples.BasicSamples/Scripts/typings/knockout/knockout.d.ts
  210. +34 −0 src/Redwood.Samples.BasicSamples/Startup.cs
  211. +59 −0 src/Redwood.Samples.BasicSamples/ViewModels/Sample1ViewModel.cs
  212. +30 −0 src/Redwood.Samples.BasicSamples/Web.Debug.config
  213. +31 −0 src/Redwood.Samples.BasicSamples/Web.Release.config
  214. +23 −0 src/Redwood.Samples.BasicSamples/Web.config
  215. +14 −0 src/Redwood.Samples.BasicSamples/packages.config
  216. +49 −0 src/Redwood.Samples.BasicSamples/sample1.rwhtml
  217. +42 −0 src/Redwood.sln
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Redwood.Framework.Binding;

namespace Redwood.Framework.Tests.Binding
{
[TestClass]
public class CommandResolverTests
{

[TestMethod]
public void CommandResolver_Valid_SimpleTest()
{
var testObject = new
{
A = new[]
{
new TestA() { StringToPass = "test" }
},
NumberToPass = 16
};

var path = new [] { "A", "[0]" };
var command = "Test(StringToPass, _parent.NumberToPass)";

var resolver = new CommandResolver();
resolver.GetFunction(testObject, path, command)();

Assert.AreEqual(testObject.NumberToPass, testObject.A[0].ResultInt);
Assert.AreEqual(testObject.A[0].ResultString, testObject.A[0].ResultString);
}

[TestMethod]
public void CommandResolver_Valid_SimpleTest2()
{
var testObject = new
{
A = new[]
{
new TestA() { StringToPass = "test" }
},
NumberToPass = 16
};

var path = new[] { "A", "[0]", "StringToPass" };
var command = "_parent.Test(_parent.StringToPass, _root.NumberToPass)";

var resolver = new CommandResolver();
resolver.GetFunction(testObject, path, command)();

Assert.AreEqual(testObject.NumberToPass, testObject.A[0].ResultInt);
Assert.AreEqual(testObject.A[0].ResultString, testObject.A[0].ResultString);
}

public class TestA
{
public string StringToPass { get; set; }

public string ResultString { get; set; }

public int ResultInt { get; set; }

public void Test(string s, int i)
{
ResultString = s;
ResultInt = i;
}
}
}
}
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Redwood.Framework.Binding;

namespace Redwood.Framework.Tests.Binding
{
[TestClass]
public class ExpressionEvaluatorTests
{

[TestMethod]
public void ExpressionEvaluator_Valid_PropertyAccess()
{
var viewModel = new
{
FirstName = "aa",
LastName = new
{
Name = "bb",
Title = new[] { 1, 2, 3 }
}
};

var evaluator = new ExpressionEvaluator();
Assert.AreEqual(viewModel.FirstName, evaluator.Evaluate("FirstName", viewModel));
Assert.AreEqual(viewModel.LastName, evaluator.Evaluate("LastName", viewModel));
Assert.AreEqual(viewModel.LastName.Name, evaluator.Evaluate("LastName.Name", viewModel));
Assert.AreEqual(viewModel.LastName.Title[2], evaluator.Evaluate("LastName.Title[2]", viewModel));
Assert.AreEqual(viewModel.LastName.Title[2], evaluator.Evaluate("_root.LastName.Title[2]", viewModel));
Assert.AreEqual(viewModel.LastName, evaluator.Evaluate("_root.LastName.Title[2]._parent", viewModel));
Assert.AreEqual(viewModel, evaluator.Evaluate("_root.LastName.Title[2]._parent._parent", viewModel));
}

[TestMethod]
public void ExpressionEvaluator_Valid_MethodResult()
{
var viewModel = new TestA() { TestProp = new TestA() };

var evaluator = new ExpressionEvaluator() { AllowMethods = true };
Assert.AreEqual(viewModel.GetType().GetMethod("Test"), evaluator.Evaluate("Test", viewModel));
Assert.AreEqual(viewModel.GetType().GetMethod("Test"), evaluator.Evaluate("_root.Test", viewModel));
Assert.AreEqual(viewModel.GetType().GetMethod("Test2"), evaluator.Evaluate("_root.TestProp.Test2", viewModel));
}

public class TestA
{
public void Test(int i)
{
}
public void Test2()
{
}

public TestA TestProp { get; set; }
}
}
}
@@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Redwood.Framework.Parser;
using Redwood.Framework.Parser.RwHtml.Parser;
using Redwood.Framework.Parser.RwHtml.Tokenizer;

namespace Redwood.Framework.Tests.Parser.RwHtml
{
[TestClass]
public class RwHtmlParserTests
{

[TestMethod]
public void RwHtmlParser_Valid_TextOnly()
{
var markup = @"this is a test";
var nodes = ParseMarkup(markup).Content;

Assert.AreEqual(1, nodes.Count);
Assert.IsInstanceOfType(nodes[0], typeof(RwHtmlLiteralNode));
}

[TestMethod]
public void RwHtmlParser_Valid_SingleElement()
{
var markup = @"this <b>is</b> a test";
var nodes = ParseMarkup(markup).Content;

Assert.AreEqual(3, nodes.Count);

Assert.IsInstanceOfType(nodes[0], typeof(RwHtmlLiteralNode));
Assert.AreEqual("this ", ((RwHtmlLiteralNode)nodes[0]).Value);

Assert.IsInstanceOfType(nodes[1], typeof(RwHtmlElementNode));
Assert.AreEqual("b", ((RwHtmlElementNode)nodes[1]).FullTagName);

Assert.IsInstanceOfType(nodes[2], typeof(RwHtmlLiteralNode));
Assert.AreEqual(" a test", ((RwHtmlLiteralNode)nodes[2]).Value);
}

[TestMethod]
public void RwHtmlParser_Valid_NestedElements()
{
var markup = @"this <b>is<a>test</a></b> a test";
var nodes = ParseMarkup(markup).Content;

var innerContent = ((RwHtmlElementNode)nodes[1]).Content;
Assert.AreEqual(2, innerContent.Count);

Assert.IsInstanceOfType(innerContent[0], typeof(RwHtmlLiteralNode));
Assert.AreEqual("is", ((RwHtmlLiteralNode)innerContent[0]).Value);

Assert.IsInstanceOfType(innerContent[1], typeof(RwHtmlElementNode));
Assert.AreEqual("a", ((RwHtmlElementNode)innerContent[1]).FullTagName);
}


[TestMethod]
public void RwHtmlParser_Valid_DoubleQuotedAttribute()
{
var markup = @"this <b>is<a href=""test of a test"">test</a></b> a test";
var nodes = ParseMarkup(markup).Content;

var innerElement = (RwHtmlElementNode)((RwHtmlElementNode)nodes[1]).Content[1];
Assert.AreEqual(1, innerElement.Attributes.Count);
Assert.AreEqual("href", innerElement.Attributes[0].Name);
Assert.IsNull(innerElement.Attributes[0].Prefix);
Assert.AreEqual("test of a test", innerElement.Attributes[0].Literal.Value);
}


[TestMethod]
public void RwHtmlParser_Valid_SingleQuotedAttribute()
{
var markup = @"this <b>is<a href='test of a test'>test</a></b> a test";
var nodes = ParseMarkup(markup).Content;

var innerElement = (RwHtmlElementNode)((RwHtmlElementNode)nodes[1]).Content[1];
Assert.AreEqual(1, innerElement.Attributes.Count);
Assert.AreEqual("href", innerElement.Attributes[0].Name);
Assert.IsNull(innerElement.Attributes[0].Prefix);
Assert.AreEqual("test of a test", innerElement.Attributes[0].Literal.Value);
}



[TestMethod]
public void RwHtmlParser_Valid_UnquotedAttribute()
{
var markup = @"this <b>is<a href=test>test</a></b> a test";
var nodes = ParseMarkup(markup).Content;

var innerElement = (RwHtmlElementNode)((RwHtmlElementNode)nodes[1]).Content[1];
Assert.AreEqual(1, innerElement.Attributes.Count);
Assert.AreEqual("href", innerElement.Attributes[0].Name);
Assert.IsNull(innerElement.Attributes[0].Prefix);
Assert.AreEqual("test", innerElement.Attributes[0].Literal.Value);
}



[TestMethod]
public void RwHtmlParser_Valid_BindingInText()
{
var markup = @"this {{value: test}} <b>is</b>";
var nodes = ParseMarkup(markup).Content;

Assert.AreEqual(4, nodes.Count);

Assert.IsInstanceOfType(nodes[0], typeof(RwHtmlLiteralNode));
Assert.AreEqual("this ", ((RwHtmlLiteralNode)nodes[0]).Value);

Assert.IsInstanceOfType(nodes[1], typeof(RwHtmlBindingNode));
Assert.AreEqual("value", ((RwHtmlBindingNode)nodes[1]).Name);
Assert.AreEqual("test", ((RwHtmlBindingNode)nodes[1]).Value);

Assert.IsInstanceOfType(nodes[2], typeof(RwHtmlLiteralNode));
Assert.AreEqual(" ", ((RwHtmlLiteralNode)nodes[2]).Value);

Assert.IsInstanceOfType(nodes[3], typeof(RwHtmlElementNode));
Assert.AreEqual("b", ((RwHtmlElementNode)nodes[3]).FullTagName);
Assert.AreEqual(1, ((RwHtmlElementNode)nodes[3]).Content.Count);
}


[TestMethod]
public void RwHtmlParser_Valid_BindingInAttributeValue()
{
var markup = @"this <a href='{value: test}'/>";
var nodes = ParseMarkup(markup).Content;

Assert.AreEqual(2, nodes.Count);

Assert.IsInstanceOfType(nodes[0], typeof(RwHtmlLiteralNode));
Assert.AreEqual("this ", ((RwHtmlLiteralNode)nodes[0]).Value);

Assert.IsInstanceOfType(nodes[1], typeof(RwHtmlElementNode));
Assert.AreEqual("a", ((RwHtmlElementNode)nodes[1]).FullTagName);
Assert.AreEqual(0, ((RwHtmlElementNode)nodes[1]).Content.Count);

Assert.AreEqual("href", ((RwHtmlElementNode)nodes[1]).Attributes[0].Name);
Assert.AreEqual("value", ((RwHtmlBindingNode)((RwHtmlElementNode)nodes[1]).Attributes[0].Literal).Name);
Assert.AreEqual("test", ((RwHtmlElementNode)nodes[1]).Attributes[0].Literal.Value);
}

// TODO: add test for this double braces - it crashes on assert, possible bug in tokenizer <a href='{{value: test}}'/>



private static RwHtmlRootNode ParseMarkup(string markup)
{
var tokenizer = new RwHtmlTokenizer(new StringReader(markup), null);
tokenizer.Tokenize();
var parser = new RwHtmlParser(tokenizer.Tokens, null);
var node = parser.Parse();
return node;
}
}
}
Oops, something went wrong.

0 comments on commit cab1c3b

Please sign in to comment.
You can’t perform that action at this time.