From 305a5f90d31df62cefbf55d11bd6e1d727c08eee Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 25 Apr 2026 23:47:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=A2=9E=E9=95=BF=E4=B8=BB=E9=94=AE=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dynamic/DataTableDynamicContextTest.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/UnitTest/Dynamic/DataTableDynamicContextTest.cs b/test/UnitTest/Dynamic/DataTableDynamicContextTest.cs index d6e6833e82b..fb297f8c96f 100644 --- a/test/UnitTest/Dynamic/DataTableDynamicContextTest.cs +++ b/test/UnitTest/Dynamic/DataTableDynamicContextTest.cs @@ -138,6 +138,28 @@ public async Task OnChanged_Ok() Assert.True(changed); } + [Fact] + public async Task AddAsync_AutoIncrementColumn_Ok() + { + var table = new DataTable(); + table.Columns.Add(new DataColumn("Id", typeof(int)) + { + AutoIncrement = true, + AutoIncrementSeed = 1, + AutoIncrementStep = 1 + }); + table.Columns.Add("Name", typeof(string)); + table.Rows.Add(null, "test-1"); + + var context = new DataTableDynamicContext(table); + + await context.AddAsync([]); + + Assert.Equal(2, table.Rows.Count); + Assert.Equal(2, table.Rows[0].Field("Id")); + Assert.Equal(1, table.Rows[1].Field("Id")); + } + [Fact] public async Task DeleteAsync_Ok() { From baf830cba648b5a255ed0c5501531c4e208395f6 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 26 Apr 2026 00:06:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/DataRowExtensionsTest.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/UnitTest/Extensions/DataRowExtensionsTest.cs diff --git a/test/UnitTest/Extensions/DataRowExtensionsTest.cs b/test/UnitTest/Extensions/DataRowExtensionsTest.cs new file mode 100644 index 00000000000..6e748c14089 --- /dev/null +++ b/test/UnitTest/Extensions/DataRowExtensionsTest.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +using System.Data; +using System.Reflection; + +namespace UnitTest.Extensions; + +public class DataRowExtensionsTest +{ + [Fact] + public void IsDeletedOrDetached_Ok() + { + var type = Type.GetType("BootstrapBlazor.Components.DataRowExtensions, BootstrapBlazor"); + Assert.NotNull(type); + + var method = type.GetMethod("IsDeletedOrDetached", BindingFlags.Static | BindingFlags.Public); + Assert.NotNull(method); + + var table = new DataTable(); + table.Columns.Add("Id", typeof(int)); + + var row = table.Rows.Add(1); + Assert.False(IsDeletedOrDetachedInvoke(row)); + table.AcceptChanges(); + + row.Delete(); + Assert.True(IsDeletedOrDetachedInvoke(row)); + + var detachedRow = table.NewRow(); + Assert.True(IsDeletedOrDetachedInvoke(detachedRow)); + + table.Rows.Add(detachedRow); + Assert.False(IsDeletedOrDetachedInvoke(detachedRow)); + + bool IsDeletedOrDetachedInvoke(DataRow row) + { + return (bool)method.Invoke(null, new object[] { row })!; + } + } +}