Skip to content

Commit

Permalink
Property with the same names defined by directive test test
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Mikuš committed Feb 12, 2024
1 parent 530ce0c commit ffaf508
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DotVVM.Framework.Tests.Runtime.ControlTree.DefaultControlTreeResolver;
using System.Linq;
using DotVVM.Framework.Compilation.ControlTree;
using DotVVM.Framework.Controls;

namespace DotVVM.Framework.Tests.Runtime.ControlTree
{
Expand Down Expand Up @@ -82,5 +80,33 @@ @viewModel object
AssertEx.BindingNode(property.Attributes[0].Initializer, "True", 62, 5);
AssertEx.BindingNode(property.Attributes[1].Initializer, "False", 106, 6);
}

[TestMethod]
public void ResolvedTree_PropertyDirectiveSameName_ErrorReported()
{
var root = ParseSource("""
@viewModel object
@property int MyProperty
@property bool MyProperty
@property string MyProperty
{{value: _control.MyProperty}}
""", "control.dotcontrol");

var firstProperty = root.Directives["property"][0] as IAbstractPropertyDeclarationDirective;
var secondProperty = root.Directives["property"][1] as IAbstractPropertyDeclarationDirective;
var thirdProperty = root.Directives["property"][2] as IAbstractPropertyDeclarationDirective;

var property = root.Metadata.FindProperty("MyProperty");

//First property wins
Assert.AreEqual(property.PropertyType, typeof(int));

Assert.IsFalse(firstProperty.DothtmlNode.HasNodeErrors);
Assert.IsTrue(secondProperty.DothtmlNode.HasNodeErrors);
Assert.IsTrue(thirdProperty.DothtmlNode.HasNodeErrors);


}
}
}

0 comments on commit ffaf508

Please sign in to comment.