using BuildFlow.Platform.Application.Menus.Commands; using BuildFlow.Platform.Application.Menus.Validators; using BuildFlow.Platform.Domain.Enums; using FluentAssertions; using Xunit; namespace BuildFlow.Platform.Tests.Menus; /// /// 菜单运行时形态校验测试。BuildFlow 自定义菜单当前只支持列表和表单两种形态。 /// public class MenuRuntimeViewModeValidatorTests { [Fact] public void CreateMenuCommand_ShouldRejectDetailRuntimeViewMode() { var validator = new CreateMenuCommandValidator(); var result = validator.Validate(new CreateMenuCommand { Code = "buildflow.form.expense.detail", FormDefinitionId = Guid.NewGuid(), Name = "BuildFlowFormExpenseDetail", Path = "/buildflow/runtime/forms/expense/detail", RenderType = MenuRenderTypeEnum.BuildFlowForm, RuntimeViewMode = MenuRuntimeViewModeEnum.Detail, Title = "费用申请详情", }); result.IsValid.Should().BeFalse(); result.Errors.Should().Contain(x => x.PropertyName == nameof(CreateMenuCommand.RuntimeViewMode) && x.ErrorMessage == "自定义表单菜单运行形态只支持列表和表单"); } [Fact] public void UpdateMenuCommand_ShouldRejectDetailRuntimeViewMode() { var validator = new UpdateMenuCommandValidator(); var result = validator.Validate(new UpdateMenuCommand { Id = 100, FormDefinitionId = Guid.NewGuid(), RenderType = MenuRenderTypeEnum.BuildFlowForm, RuntimeViewMode = MenuRuntimeViewModeEnum.Detail, }); result.IsValid.Should().BeFalse(); result.Errors.Should().Contain(x => x.PropertyName == nameof(UpdateMenuCommand.RuntimeViewMode) && x.ErrorMessage == "自定义表单菜单运行形态只支持列表和表单"); } }