コード例 #1
0
ファイル: ResourceTests.cs プロジェクト: CarlSosaDev/Avalonia
        public void FindStyleResource_Should_Find_Correct_Resource()
        {
            Border target;

            var tree = new Decorator
            {
                Styles = new Styles
                {
                    new Style
                    {
                        Resources = new Dictionary<string, object>
                        {
                            { "Foo", "foo resource" },
                            { "Bar", "overridden" },
                        }
                    }
                },
                Child = target = new Border
                {
                    Styles = new Styles
                    {
                        new Style
                        {
                            Resources = new Dictionary<string, object>
                            {
                                { "Bar", "again overridden" },
                            }
                        },
                        new Style
                        {
                            Resources = new Dictionary<string, object>
                            {
                                { "Bar", "bar resource" },
                            }
                        }
                    }
                }
            };

            Assert.Equal("foo resource", target.FindStyleResource("Foo"));
            Assert.Equal("bar resource", target.FindStyleResource("Bar"));
        }
コード例 #2
0
ファイル: ResourceTests.cs プロジェクト: CarlSosaDev/Avalonia
        public void FindStyleResource_Should_Return_UnsetValue_For_Not_Found()
        {
            Border target;

            var tree = target = new Border
            {
                Styles = new Styles
                    {
                        new Style
                        {
                            Resources = new Dictionary<string, object>
                            {
                                { "Foo", "foo" },
                            }
                        },
                    }
            };

            Assert.Equal(AvaloniaProperty.UnsetValue, target.FindStyleResource("Baz"));
        }