diff --git a/.github/workflows/nuke-test.yml b/.github/workflows/nuke-test.yml index ad39e48..58f7a20 100644 --- a/.github/workflows/nuke-test.yml +++ b/.github/workflows/nuke-test.yml @@ -19,4 +19,4 @@ jobs: run: dotnet restore - name: Run Nuke Build Test - run: ./build.cmd Test || ./build.sh Test \ No newline at end of file + run: ./build.sh Test \ No newline at end of file diff --git a/tests/LuYao.Common.UnitTests/Data/RecordTests.cs b/tests/LuYao.Common.UnitTests/Data/RecordTests.cs index 1e8386d..5b2a036 100644 --- a/tests/LuYao.Common.UnitTests/Data/RecordTests.cs +++ b/tests/LuYao.Common.UnitTests/Data/RecordTests.cs @@ -27,8 +27,8 @@ public void AddRowAndSetColumnValue_WorksCorrectly() { // Arrange var table = new Record(); - var colId = table.Columns.Add("Id"); // 滻 Add Ϊ Add - var colName = table.Columns.Add("Name"); // 滻 Add Ϊ Add + var colId = table.Columns.Add("Id"); // 替换 Add 为 Add + var colName = table.Columns.Add("Name"); // 替换 Add 为 Add // Act var row = table.AddRow(); @@ -38,8 +38,8 @@ public void AddRowAndSetColumnValue_WorksCorrectly() // Assert Assert.AreEqual(1, table.Count); Assert.AreEqual(2, table.Columns.Count); - Assert.AreEqual(1, colId.Get(row.Row)); // 滻 GetValue Ϊ Get - Assert.AreEqual("Test", colName.Get(row.Row)); // 滻 GetValue Ϊ Get + Assert.AreEqual(1, colId.Get(row.Row)); // 替换 GetValue 为 Get + Assert.AreEqual("Test", colName.Get(row.Row)); // 替换 GetValue 为 Get } [TestMethod] @@ -60,9 +60,9 @@ public void AddMultipleRowsAndColumns_WorksCorrectly() { // Arrange var table = new Record(); - var colId = table.Columns.Add("Id"); // 滻 Add Ϊ Add - var colName = table.Columns.Add("Name"); // 滻 Add Ϊ Add - var colAge = table.Columns.Add("Age"); // 滻 Add Ϊ Add + var colId = table.Columns.Add("Id"); // 替换 Add 为 Add + var colName = table.Columns.Add("Name"); // 替换 Add 为 Add + var colAge = table.Columns.Add("Age"); // 替换 Add 为 Add // Act var row1 = table.AddRow(); @@ -79,13 +79,13 @@ public void AddMultipleRowsAndColumns_WorksCorrectly() Assert.AreEqual(2, table.Count); Assert.AreEqual(3, table.Columns.Count); - Assert.AreEqual(1, colId.Get(row1.Row)); // 滻 GetValue Ϊ Get - Assert.AreEqual("Alice", colName.Get(row1.Row)); // 滻 GetValue Ϊ Get - Assert.AreEqual(25, colAge.Get(row1.Row)); // 滻 GetValue Ϊ Get + Assert.AreEqual(1, colId.Get(row1.Row)); // 替换 GetValue 为 Get + Assert.AreEqual("Alice", colName.Get(row1.Row)); // 替换 GetValue 为 Get + Assert.AreEqual(25, colAge.Get(row1.Row)); // 替换 GetValue 为 Get - Assert.AreEqual(2, colId.Get(row2.Row)); // 滻 GetValue Ϊ Get - Assert.AreEqual("Bob", colName.Get(row2.Row)); // 滻 GetValue Ϊ Get - Assert.AreEqual(30, colAge.Get(row2.Row)); // 滻 GetValue Ϊ Get + Assert.AreEqual(2, colId.Get(row2.Row)); // 替换 GetValue 为 Get + Assert.AreEqual("Bob", colName.Get(row2.Row)); // 替换 GetValue 为 Get + Assert.AreEqual(30, colAge.Get(row2.Row)); // 替换 GetValue 为 Get } [TestMethod] @@ -277,7 +277,7 @@ public void RowImplicitConversion_WorksCorrectly() var row = rows[1]; // Act - int rowIndex = row; // ʽת + int rowIndex = row; // 隐式转换 // Assert Assert.AreEqual(1, rowIndex); @@ -681,7 +681,7 @@ public void ToString_LongStringValue_TruncatesWithEllipsis() Assert.IsTrue(result.Contains("..") || result.Contains("LongStringTest")); } - // ı߽Է + // 新增的边界检查测试方法 [TestMethod] public void GetValue_NegativeRowIndex_ThrowsArgumentOutOfRangeException() @@ -693,7 +693,7 @@ public void GetValue_NegativeRowIndex_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.GetValue(-1)); - Assert.IsTrue(exception.Message.Contains(" -1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 -1 超出有效范围")); } [TestMethod] @@ -706,7 +706,7 @@ public void GetValue_RowIndexEqualToCount_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.GetValue(1)); - Assert.IsTrue(exception.Message.Contains(" 1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 1 超出有效范围")); } [TestMethod] @@ -719,7 +719,7 @@ public void GetValue_RowIndexGreaterThanCount_ThrowsArgumentOutOfRangeException( // Act & Assert var exception = Assert.Throws(() => col.GetValue(5)); - Assert.IsTrue(exception.Message.Contains(" 5 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 5 超出有效范围")); } [TestMethod] @@ -732,7 +732,7 @@ public void SetValue_NegativeRowIndex_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.SetValue("test", -1)); - Assert.IsTrue(exception.Message.Contains(" -1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 -1 超出有效范围")); } [TestMethod] @@ -745,7 +745,7 @@ public void SetValue_RowIndexEqualToCount_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.SetValue("test", 1)); - Assert.IsTrue(exception.Message.Contains(" 1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 1 超出有效范围")); } [TestMethod] @@ -758,7 +758,7 @@ public void SetValue_RowIndexGreaterThanCount_ThrowsArgumentOutOfRangeException( // Act & Assert var exception = Assert.Throws(() => col.SetValue("test", 5)); - Assert.IsTrue(exception.Message.Contains(" 5 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 5 超出有效范围")); } [TestMethod] @@ -771,7 +771,7 @@ public void SetBoolean_NegativeIndex_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.Set(true, -1)); - Assert.IsTrue(exception.Message.Contains(" -1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 -1 超出有效范围")); } [TestMethod] @@ -784,7 +784,7 @@ public void SetBoolean_IndexEqualToCount_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.Set(true, 1)); - Assert.IsTrue(exception.Message.Contains(" 1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 1 超出有效范围")); } [TestMethod] @@ -797,7 +797,7 @@ public void SetInt32_IndexGreaterThanCount_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.Set(42, 5)); - Assert.IsTrue(exception.Message.Contains(" 5 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 5 超出有效范围")); } [TestMethod] @@ -810,7 +810,7 @@ public void ToBoolean_NegativeIndex_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.Get(-1)); - Assert.IsTrue(exception.Message.Contains(" -1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 -1 超出有效范围")); } [TestMethod] @@ -823,7 +823,7 @@ public void ToInt32_IndexEqualToCount_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.Get(1)); - Assert.IsTrue(exception.Message.Contains(" 1 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 1 超出有效范围")); } [TestMethod] @@ -836,7 +836,7 @@ public void ToString_IndexGreaterThanCount_ThrowsArgumentOutOfRangeException() // Act & Assert var exception = Assert.Throws(() => col.Get(10)); - Assert.IsTrue(exception.Message.Contains(" 10 ЧΧ")); + Assert.IsTrue(exception.Message.Contains("行索引 10 超出有效范围")); } [TestMethod] @@ -1014,7 +1014,7 @@ public void Columns_AddDuplicateName_ThrowsException() table.Columns.Add("TestColumn"); // Act & Assert - Assert.Throws(() => table.Columns.Add("TestColumn")); // Ӧ׳쳣 + Assert.Throws(() => table.Columns.Add("TestColumn")); // 应该抛出异常 } [TestMethod] @@ -1025,7 +1025,7 @@ public void Columns_AddDuplicateNameDifferentType_ThrowsException() table.Columns.Add("TestColumn"); // Act & Assert - Assert.Throws(() => table.Columns.Add("TestColumn")); // Ӧ׳쳣 + Assert.Throws(() => table.Columns.Add("TestColumn")); // 应该抛出异常 } public class Student diff --git a/tests/LuYao.Common.UnitTests/Net/Http/HttpResponseMessageExtensionsTests.cs b/tests/LuYao.Common.UnitTests/Net/Http/HttpResponseMessageExtensionsTests.cs index 7bd519e..bfb4945 100644 --- a/tests/LuYao.Common.UnitTests/Net/Http/HttpResponseMessageExtensionsTests.cs +++ b/tests/LuYao.Common.UnitTests/Net/Http/HttpResponseMessageExtensionsTests.cs @@ -28,7 +28,7 @@ await Assert.ThrowsAsync(async () => public async Task ReadAsHtmlAsync_CharsetInHeader_UsesHeaderEncoding() { // Arrange - var content = new StringContent("", Encoding.Unicode); + var content = new StringContent("测试内容", Encoding.Unicode); if (content.Headers.ContentType != null) { content.Headers.ContentType.CharSet = "utf-16"; @@ -42,14 +42,14 @@ public async Task ReadAsHtmlAsync_CharsetInHeader_UsesHeaderEncoding() var result = await response.ReadAsHtmlAsync(); // Assert - Assert.AreEqual("", result); + Assert.AreEqual("测试内容", result); } [TestMethod] public async Task ReadAsHtmlAsync_CharsetInHtml_UsesHtmlEncoding() { // Arrange - var html = "
"; + var html = "
中文内容
"; var bytes = Encoding.GetEncoding("gb2312").GetBytes(html); var content = new ByteArrayContent(bytes); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html"); @@ -62,14 +62,14 @@ public async Task ReadAsHtmlAsync_CharsetInHtml_UsesHtmlEncoding() var result = await response.ReadAsHtmlAsync(); // Assert - Assert.IsTrue(result.Contains("")); + Assert.IsTrue(result.Contains("中文内容")); } [TestMethod] public async Task ReadAsHtmlAsync_NoCharset_UsesUtf8ByDefault() { // Arrange - var text = "ĬUTF8"; + var text = "默认UTF8内容"; var bytes = Encoding.UTF8.GetBytes(text); var content = new ByteArrayContent(bytes); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain");