public void StandardPropertyAssignmentOfItemsToCollection() { var sut = new MemberAssigmentApplier(new NoActionValuePipeline()); var nodes = new List <ConstructionNode>() { new ConstructionNode { Instance = "A", }, new ConstructionNode { Instance = "B", } }; var assignment = new MemberAssignment { Member = Member.FromStandard <ItemsControl>(tb => tb.Items), Values = nodes, }; var itemsControl = new ItemsControl(); sut.ExecuteAssignment(new NodeAssignment(assignment, itemsControl), null, null); Assert.Equal(new[] { "A", "B" }, itemsControl.Items); }
public void ResultCollectionExtensionIsAssignedToCollectionProperty() { var sut = new MemberAssigmentApplier(new MarkupExtensionValuePipeline(new NoActionValuePipeline())); var constructionNode = new ConstructionNode <CollectionExtension> { Instance = new CollectionExtension(), IsCreated = true, }; var assignment = new NodeAssignment(new MemberAssignment <ItemsControl>(control => control.Items, constructionNode), new ItemsControl()); sut.ExecuteAssignment(assignment, null, null); }
public void IncompatibleInstances() { var sut = new MemberAssigmentApplier(new NoActionValuePipeline()); var nodes = new List <ConstructionNode> { new ConstructionNode { Instance = "12.5", }, }; var assignment = new MemberAssignment { Member = Member.FromStandard <Window>(w => w.Height), Values = nodes }; var window = new Window(); Assert.Throws <ArgumentException>(() => sut.ExecuteAssignment(new NodeAssignment(assignment, window), null, null)); }
public void AttachedPropertyAssignment() { var sut = new MemberAssigmentApplier(new NoActionValuePipeline()); var textBlock = new TextBlock(); var nodes = new List <ConstructionNode>() { new ConstructionNode() { Instance = 1 } }; var assignment = new MemberAssignment { Member = Member.FromAttached <Grid>("Row"), Values = nodes, }; sut.ExecuteAssignment(new NodeAssignment(assignment, textBlock), null, null); Assert.Equal(1, Grid.GetRow(textBlock)); }
public void StandardPropertyAssignmentWithOneChild() { var sut = new MemberAssigmentApplier(new NoActionValuePipeline()); var textBlock = new TextBlock(); var nodes = new List <ConstructionNode> { new ConstructionNode { Instance = "SomeText", } }; var assignment = new MemberAssignment { Member = Member.FromStandard <TextBlock>(tb => tb.Text), Values = nodes, }; sut.ExecuteAssignment(new NodeAssignment(assignment, textBlock), null, null); Assert.Equal("SomeText", textBlock.Text); }
public void StandardPropertyAssignmentWithMoreThanOneChild() { var sut = new MemberAssigmentApplier(new NoActionValuePipeline()); var nodes = new List <ConstructionNode> { new ConstructionNode() { Instance = "SomeText", }, new ConstructionNode { Instance = "SomeText", } }; var assignment = new MemberAssignment { Member = Member.FromStandard <TextBlock>(tb => tb.Text), Values = nodes, }; Assert.Throws <InvalidOperationException>(() => sut.ExecuteAssignment(new NodeAssignment(assignment, null), null, null)); }