mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 13:39:39 +08:00
!3530 test(#I614VE): update unit test improve code coverage
* test: 增加 DateTimePickerRange 单元测试 * test: 增加 DateTimePickerRange 单元测试 * refactor: 精简代码 * chore: 调整 RibbonTab 样式 * doc: 更新注释 * refactor: 重构代码 * test: 增加 GetStartTime 单元测试 * refactor: 更改代码提高代码覆盖率 * refactor: 移除编译条件 * test: 增加动态列单元测试
This commit is contained in:
parent
d8d22debd7
commit
73a5823278
@ -23,7 +23,7 @@ public class AutoRedirect : BootstrapModuleComponentBase
|
||||
public bool IsForceLoad { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 自动锁屏间隔单位 秒 默认 60000 秒
|
||||
/// 获得/设置 自动锁屏间隔单位 秒 默认 60000 毫秒
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int Interval { get; set; } = 60000;
|
||||
|
@ -1,7 +1,14 @@
|
||||
.ribbon-tab {
|
||||
--bb-ribbon-tabs-header-bg: #f5f7fa;
|
||||
--bb-ribbon-tabs-item-color: #343a40;
|
||||
--bb-ribbon-tabs-item-hover-color: #409eff;
|
||||
--bb-ribbon-menu-height: 30px;
|
||||
--bb-ribbon-menu-margin-top: 10px;
|
||||
--bb-ribbon-menu-body-height: 82.5px;
|
||||
--bb-ribbon-menu-body-padding: .5rem;
|
||||
--bb-ribbon-menu-radius: var(--bs-border-radius);
|
||||
--bb-ribbon-menu-padding: .5rem;
|
||||
--bb-ribbon-menu-border-color: var(--bs-border-color);
|
||||
--bb-ribbon-menu-bg: #f5f7fa;
|
||||
--bb-ribbon-menu-color: #343a40;
|
||||
--bb-ribbon-menu-hover-color: #409eff;
|
||||
--bb-ribbon-button-hover-bg: #d0e7ff;
|
||||
--bb-ribbon-button-hover-border-color: #8bb5e0;
|
||||
--bb-ribbon-button-active-bg: #acd4fd;
|
||||
@ -12,17 +19,11 @@
|
||||
--bb-ribbon-button-padding: 0.25rem;
|
||||
--bb-ribbon-button-fontsize: 0.75rem;
|
||||
--bb-ribbon-button-min-width: 56px;
|
||||
--bb-ribbon-content-height: 82.5px;
|
||||
--bb-ribbon-command-padding: .5rem;
|
||||
--bb-ribbon-group-fontsize: 11px;
|
||||
--bb-ribbon-group-color: #adb5bd;
|
||||
--bb-ribbon-group-margin-top: .25rem;
|
||||
--bb-ribbon-item-height: 30px;
|
||||
--bb-ribbon-item-radius: var(--bs-border-radius);
|
||||
--bb-ribbon-item-padding: .5rem;
|
||||
--bb-ribbon-item-margin-top: 10px;
|
||||
--bb-ribbon-item-border-color: var(--bs-border-color);
|
||||
--bb-ribbon-body-padding: 1rem;
|
||||
--bb-ribbon-menu-header-height: calc(var(--bb-ribbon-menu-height) + var(--bb-ribbon-menu-margin-top) + var(--bb-ribbon-menu-body-height));
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
@ -34,7 +35,7 @@
|
||||
.ribbon-tab .ribbon-header .tabs-border-card.tabs-top .tabs-header {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
background-color: var(--bb-ribbon-tabs-header-bg);
|
||||
background-color: var(--bb-ribbon-menu-bg);
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card {
|
||||
@ -44,38 +45,38 @@
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card .tabs-header .tabs-item {
|
||||
padding: 0 var(--bb-ribbon-item-padding);
|
||||
margin-top: var(--bb-ribbon-item-margin-top);
|
||||
height: var(--bb-ribbon-item-height);
|
||||
border-top-left-radius: var(--bb-ribbon-item-radius);
|
||||
border-top-right-radius: var(--bb-ribbon-item-radius);
|
||||
padding: 0 var(--bb-ribbon-menu-padding);
|
||||
margin-top: var(--bb-ribbon-menu-margin-top);
|
||||
height: var(--bb-ribbon-menu-height);
|
||||
border-top-left-radius: var(--bb-ribbon-menu-radius);
|
||||
border-top-right-radius: var(--bb-ribbon-menu-radius);
|
||||
transition: background-color .3s ease-in-out, color .3s ease-in-out, border-right-color .3s ease-in-out, border-left-color .3s ease-in-out;
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card .tabs-header .tabs-item.active {
|
||||
border-left-color: var(--bb-ribbon-item-border-color);
|
||||
border-right-color: var(--bb-ribbon-item-border-color);
|
||||
border-top-color: var(--bb-ribbon-item-border-color);
|
||||
border-left-color: var(--bb-ribbon-menu-border-color);
|
||||
border-right-color: var(--bb-ribbon-menu-border-color);
|
||||
border-top-color: var(--bb-ribbon-menu-border-color);
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card .tabs-header .tabs-item:nth-child(2) {
|
||||
padding-left: var(--bb-ribbon-item-padding);
|
||||
padding-left: var(--bb-ribbon-menu-padding);
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card .tabs-header .tabs-item:last-child {
|
||||
padding-right: var(--bb-ribbon-item-padding);
|
||||
padding-right: var(--bb-ribbon-menu-padding);
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card .tabs-header .tabs-item:not(:hover):not(.active) {
|
||||
color: var(--bb-ribbon-tabs-item-color);
|
||||
color: var(--bb-ribbon-menu-color);
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-header .tabs-border-card .tabs-header .tabs-item:hover {
|
||||
color: var(--bb-ribbon-tabs-item-hover-color);
|
||||
color: var(--bb-ribbon-menu-hover-color);
|
||||
}
|
||||
|
||||
.ribbon-tab .tabs-nav-scroll {
|
||||
padding: 0 var(--bb-ribbon-item-padding);
|
||||
padding: 0 var(--bb-ribbon-menu-padding);
|
||||
}
|
||||
|
||||
.ribbon-tab .tabs .tabs-body {
|
||||
@ -84,7 +85,7 @@
|
||||
|
||||
.ribbon-tab .tabs-body-content {
|
||||
overflow: hidden;
|
||||
height: var(--bb-ribbon-content-height);
|
||||
height: var(--bb-ribbon-menu-body-height);
|
||||
transition: height .3s ease-in-out;
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@
|
||||
flex-wrap: nowrap;
|
||||
font-size: var(--bb-ribbon-button-fontsize);
|
||||
overflow: hidden;
|
||||
padding: var(--bb-ribbon-command-padding);
|
||||
padding: var(--bb-ribbon-menu-body-padding);
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@ -160,8 +161,8 @@
|
||||
.ribbon-tab .ribbon-buttons {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
top: var(--bb-ribbon-item-margin-top);
|
||||
height: var(--bb-ribbon-item-height);
|
||||
top: var(--bb-ribbon-menu-margin-top);
|
||||
height: var(--bb-ribbon-menu-height);
|
||||
}
|
||||
|
||||
.ribbon-tab .ribbon-buttons,
|
||||
|
@ -255,7 +255,7 @@ public partial class Select<TValue> : ISelect
|
||||
// 触发 SelectedItemChanged 事件
|
||||
if (OnSelectedItemChanged != null)
|
||||
{
|
||||
await OnSelectedItemChanged.Invoke(SelectedItem);
|
||||
await OnSelectedItemChanged(SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,7 @@ internal class CacheManager : ICacheManager
|
||||
var sections = Instance.GetOrCreate(key, entry => option.GetJsonStringFromAssembly(assembly, cultureName));
|
||||
return sections?.FirstOrDefault(kv => typeName.Equals(kv.Key, StringComparison.OrdinalIgnoreCase))?
|
||||
.GetChildren()
|
||||
#if NET7_0_OR_GREATER
|
||||
.SelectMany(kv => new[] { new LocalizedString(kv.Key, kv.Value ?? kv.Key) });
|
||||
#else
|
||||
.SelectMany(kv => new[] { new LocalizedString(kv.Key, kv.Value) });
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -232,11 +228,7 @@ internal class CacheManager : ICacheManager
|
||||
/// </summary>
|
||||
/// <param name="includeParentCultures"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<LocalizedString> GetAllStringsFromResolve(bool includeParentCultures = true) => Instance.GetOrCreate($"{nameof(GetAllStringsFromResolve)}-{CultureInfo.CurrentUICulture.Name}", entry => Instance.Provider.GetRequiredService<ILocalizationResolve>().GetAllStringsByCulture(includeParentCultures))
|
||||
#if NET7_0_OR_GREATER
|
||||
?? Enumerable.Empty<LocalizedString>()
|
||||
#endif
|
||||
;
|
||||
public static IEnumerable<LocalizedString> GetAllStringsFromResolve(bool includeParentCultures = true) => Instance.GetOrCreate($"{nameof(GetAllStringsFromResolve)}-{CultureInfo.CurrentUICulture.Name}", entry => Instance.Provider.GetRequiredService<ILocalizationResolve>().GetAllStringsByCulture(includeParentCultures));
|
||||
#endregion
|
||||
|
||||
#region DisplayName
|
||||
@ -338,7 +330,7 @@ internal class CacheManager : ICacheManager
|
||||
var stringLocalizer = localizerAttr![itemName];
|
||||
return stringLocalizer.Value;
|
||||
}
|
||||
}) ?? new();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -383,7 +375,7 @@ internal class CacheManager : ICacheManager
|
||||
if (localizer != null)
|
||||
{
|
||||
var stringLocalizer = localizer[$"{fieldName}.PlaceHolder"];
|
||||
if (stringLocalizer is { ResourceNotFound: false })
|
||||
if (!stringLocalizer.ResourceNotFound)
|
||||
{
|
||||
ret = stringLocalizer.Value;
|
||||
}
|
||||
@ -586,7 +578,10 @@ internal class CacheManager : ICacheManager
|
||||
body = Expression.Call(Expression.Convert(exp_p1, type), mi);
|
||||
}
|
||||
}
|
||||
return body == null
|
||||
return BuildExpression();
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
Expression<Func<object, string, IFormatProvider?, string>> BuildExpression() => body == null
|
||||
? (s, f, provider) => s.ToString() ?? ""
|
||||
: Expression.Lambda<Func<object, string, IFormatProvider?, string>>(body, exp_p1, exp_p2, exp_p3);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -210,7 +210,7 @@ public class DateTimeRangeTest : BootstrapBlazorTestBase
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateValue_Ok()
|
||||
public void UpdateValue_Year()
|
||||
{
|
||||
var cut = Context.RenderComponent<DateTimeRange>(builder =>
|
||||
{
|
||||
@ -232,6 +232,34 @@ public class DateTimeRangeTest : BootstrapBlazorTestBase
|
||||
cut.FindAll(".date-table .cell").Last().Click();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateValue_Month()
|
||||
{
|
||||
var cut = Context.RenderComponent<DateTimeRange>(builder =>
|
||||
{
|
||||
builder.Add(a => a.Value, new DateTimeRangeValue()
|
||||
{
|
||||
Start = new DateTime(2022, 11, 1),
|
||||
End = new DateTime(2022, 11, 14)
|
||||
});
|
||||
});
|
||||
|
||||
// 翻页下一月
|
||||
var next = cut.Find(".picker-panel-icon-btn.pick-panel-arrow-right");
|
||||
cut.InvokeAsync(() => next.Click());
|
||||
|
||||
var cells = cut.FindAll(".date-table tbody .cell");
|
||||
// 选择开始时间
|
||||
cells.ElementAt(7).Click();
|
||||
// 选择结束时间
|
||||
cells.ElementAt(37).Click();
|
||||
|
||||
// 选择开始时间
|
||||
cells.ElementAt(7).Click();
|
||||
// 选择结束时间
|
||||
cells.ElementAt(47).Click();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task InValidateForm_Ok()
|
||||
{
|
||||
|
@ -9,8 +9,19 @@ public class CacheManagerTest : BootstrapBlazorTestBase
|
||||
[Fact]
|
||||
public void GetStartTime_Ok()
|
||||
{
|
||||
Cache.SetStartTime();
|
||||
Cache.Clear("BootstrapBlazor_StartTime");
|
||||
var v = Cache.GetStartTime();
|
||||
Assert.Equal(DateTimeOffset.MinValue, v);
|
||||
|
||||
Cache.GetOrCreate("BootstrapBlazor_StartTime", entry =>
|
||||
{
|
||||
return 10;
|
||||
});
|
||||
var v1 = Cache.GetStartTime();
|
||||
Assert.Equal(DateTimeOffset.MinValue, v);
|
||||
|
||||
Cache.Clear("BootstrapBlazor_StartTime");
|
||||
Cache.SetStartTime();
|
||||
Assert.True(DateTime.Now > Cache.GetStartTime());
|
||||
}
|
||||
|
||||
|
@ -387,6 +387,10 @@ public class UtilityTest : BootstrapBlazorTestBase
|
||||
foo.Name = v1;
|
||||
Utility.SetPropertyValue<object, object>(foo, nameof(Foo.Name), val);
|
||||
Assert.Equal(foo.Name, val);
|
||||
|
||||
var model = new DynamicColumnsObject();
|
||||
Utility.SetPropertyValue<object, object>(model, "Name", "Test-Value");
|
||||
Assert.Equal("Test-Value", Utility.GetPropertyValue(model, "Name"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
Loading…
Reference in New Issue
Block a user