Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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));
        }
Example #4
0
        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));
        }
Example #5
0
        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);
        }
Example #6
0
        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));
        }