借助网络配置,控制Modbus工具的日志显示,避免卡死界面
智能大石头 authored at 2021-12-11 22:09:19
1.59 KiB
XCoder
using System.ComponentModel;
using System.Threading.Tasks;
using Avalonia.Controls;
using NewLife.XCoder.Services;
using NewLife.XCoder.Shell;
using Xunit;

namespace XCoder.App.UiTests;

/// <summary>外壳品牌区:左上角名称与左下角版本号</summary>
/// <remarks>品牌名走词表(<c>XCoder</c> 键),版本号跟随 <see cref="AppInfo"/>,回归时防止又写死成固定文案而与发布包脱节。</remarks>
public class ShellBrandTests
{
    [Fact]
    [DisplayName("侧栏品牌名与版本号取自 AppInfo")]
    public Task Sidebar_ShowsAppInfo() => UiSession.Run(() =>
    {
        var window = new ShellWindow();

        Assert.Equal(AppInfo.DisplayName, window.Title);
        Assert.Equal(LocalizationService.T("XCoder"), window.FindControl<TextBlock>("BrandName")!.Text);
        Assert.Equal(AppInfo.VersionText, window.FindControl<TextBlock>("VersionText")!.Text);

        return Task.CompletedTask;
    });

    [Fact]
    [DisplayName("语言切换后版本号仍在,品牌名跟随词表")]
    public Task Sidebar_KeepsVersionAfterLanguageSwitch() => UiSession.Run(() =>
    {
        var old = LocalizationService.Preference;
        var window = new ShellWindow();

        try
        {
            LocalizationService.Apply("en-US", false);

            Assert.Equal("XCoder", window.FindControl<TextBlock>("BrandName")!.Text);
            Assert.Equal(AppInfo.VersionText, window.FindControl<TextBlock>("VersionText")!.Text);
        }
        finally
        {
            LocalizationService.Apply(old, false);
        }

        return Task.CompletedTask;
    });
}