public async Task OutlinedButton_BorderCanBeOverridden()
        {
            await using var recorder = new TestRecorder(App);

            //Arrange
            var button = await LoadXaml <Button>(
                @"<Button Content=""Button""
                          Style=""{StaticResource MaterialDesignOutlinedButton}""
                          BorderThickness=""5""
                          BorderBrush=""Red""
                    />");

            Color midColor = await GetThemeColor("PrimaryHueMidBrush");

            IVisualElement <Border> internalBorder = await button.GetElement <Border>("border");

            //Act
            Thickness borderThickness = await internalBorder.GetBorderThickness();

            Color?borderBrush = await internalBorder.GetBorderBrushColor();

            //Assert
            Assert.Equal(new Thickness(5), borderThickness);
            Assert.Equal(Colors.Red, borderBrush);

            recorder.Success();
        }
示例#2
0
    public async Task OnLoad_ThemeBrushesSet()
    {
        await using var recorder = new TestRecorder(App);

        //Arrange
        IVisualElement <TabControl> tabControl = await LoadXaml <TabControl>(@"
<TabControl 
        materialDesign:ColorZoneAssist.Mode=""PrimaryMid""
        Style=""{StaticResource MaterialDesignFilledTabControl}"">
    <TabItem Header=""TAB 1"">
        <TextBlock Margin=""8"" Text=""PrimaryMid Tab 1"" />
    </TabItem>
    <TabItem Header=""TAB 2"">
        <TextBlock Margin=""8"" Text=""PrimaryMid Tab 2"" />
    </TabItem>
</TabControl>");

        IVisualElement <TextBlock> textBlock = await tabControl.GetElement <TextBlock>(@"/TabItem[0]/TextBlock[0]");

        IVisualElement <Border> selectedTabBorder = await tabControl.GetElement <Border>(@"/TabItem[0]~SelectionHighlightBorder");

        //Act
        Color?foreground = await textBlock.GetForegroundColor();

        Color?background = await textBlock.GetEffectiveBackground();

        Color?selectedTabUnderline = await selectedTabBorder.GetBorderBrushColor();

        //Assert
        Assert.NotNull(foreground);
        Assert.NotNull(background);

        MaterialDesignSpec.AssertContrastRatio(foreground.Value, background.Value, MaterialDesignSpec.MinimumContrastSmallText);

        Assert.Equal(foreground, selectedTabUnderline);

        recorder.Success();
    }
        public async Task OutlinedButton_UsesThemeColorForBorder()
        {
            await using var recorder = new TestRecorder(App);

            //Arrange
            IVisualElement <Button> button = await LoadXaml <Button>(
                @"<Button Content=""Button"" Style=""{StaticResource MaterialDesignOutlinedButton}""/>");

            Color midColor = await GetThemeColor("PrimaryHueMidBrush");

            IVisualElement <Border> internalBorder = await button.GetElement <Border>("border");

            //Act
            Color?borderColor = await button.GetBorderBrushColor();

            Color?internalBorderColor = await internalBorder.GetBorderBrushColor();

            //Assert
            Assert.Equal(midColor, borderColor);
            Assert.Equal(midColor, internalBorderColor);

            recorder.Success();
        }