Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions build/_build.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="9.0.4" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion build/configureawait.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<ItemGroup>
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.2" PrivateAssets="All" />
<PackageReference Include="Fody" Version="6.9.2">
<PackageReference Include="Fody" Version="6.9.3">
<PrivateAssets>All</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 4 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion src/LuYao.Common/LuYao.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\configureawait.props" />
<PropertyGroup>
<TargetFrameworks>net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0</TargetFrameworks>
<RootNamespace>LuYao</RootNamespace>
<Title>LuYao.Common</Title>
<LangVersion>latest</LangVersion>
Expand Down
10 changes: 4 additions & 6 deletions src/LuYao.Text.Json.Jint/LuYao.Text.Json.Jint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\configureawait.props" />
<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<RootNamespace>LuYao.Text.Json</RootNamespace>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\docs\luyao.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Assembly.cs" Link="Assembly.cs" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Jint" Version="4.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Jint" Version="4.4.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/LuYao.Text.Json/LuYao.Text.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\configureawait.props" />
<PropertyGroup>
<TargetFrameworks>net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<SignAssembly>True</SignAssembly>
Expand All @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task DequeueAsync_NoItem_CancellationTokenTriggersException()
cts.Cancel();

// Act & Assert
await Assert.ThrowsExceptionAsync<TaskCanceledException>(async () =>
await Assert.ThrowsExactlyAsync<TaskCanceledException>(async () =>
{
await queue.DequeueAsync(cts.Token);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,23 @@ public void SplitToBatch_ListWithRemainder_ReturnsLastBatchWithFewerItems()
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void SplitToBatch_NullSource_ThrowsArgumentNullException()
{
List<int>? input = null;
_ = input.SplitToBatch(2).ToList();
Assert.ThrowsExactly<ArgumentNullException>(() => input.SplitToBatch(2).ToList());
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void SplitToBatch_BatchSizeZero_ThrowsArgumentOutOfRangeException()
{
var input = Enumerable.Range(1, 3);
_ = input.SplitToBatch(0).ToList();
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => input.SplitToBatch(0).ToList());
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void SplitToBatch_BatchSizeNegative_ThrowsArgumentOutOfRangeException()
{
var input = Enumerable.Range(1, 3);
_ = input.SplitToBatch(-1).ToList();
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => input.SplitToBatch(-1).ToList());
}
}
98 changes: 51 additions & 47 deletions tests/LuYao.Common.UnitTests/Collections/Generic/KeyedListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ public void Constructor_WithValidKeySelector_CreatesInstance()
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]


public void Constructor_WithNullKeySelector_ThrowsArgumentNullException()


{
// Arrange & Act
var keyedList = new KeyedList<int, TestItem>(null!);

// Assert: 期望抛出 ArgumentNullException

// Arrange, Act & Assert


Assert.ThrowsExactly<ArgumentNullException>(() => new KeyedList<int, TestItem>(null!));


}

#endregion
Expand All @@ -87,13 +94,20 @@ public void Indexer_GetWithValidIndex_ReturnsCorrectItem()
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]


public void Indexer_GetWithInvalidIndex_ThrowsArgumentOutOfRangeException()


{
// Arrange & Act
var item = _keyedList[-1];

// Assert: 期望抛出 ArgumentOutOfRangeException

// Arrange, Act & Assert


Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList[-1]);


}

[TestMethod]
Expand All @@ -110,16 +124,27 @@ public void Indexer_SetWithValidIndex_UpdatesItem()
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]


public void Indexer_SetWithInvalidIndex_ThrowsArgumentOutOfRangeException()


{


// Arrange


var newItem = new TestItem { Id = 10, Name = "New Item" };

// Act
_keyedList[10] = newItem;

// Assert: 期望抛出 ArgumentOutOfRangeException

// Act & Assert


Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList[10] = newItem);


}

#endregion
Expand Down Expand Up @@ -375,39 +400,30 @@ public void CopyTo_ValidArrayWithOffset_CopiesItemsWithOffset()
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void CopyTo_NullArray_ThrowsArgumentNullException()
{
// Arrange & Act
_keyedList.CopyTo(null!, 0);

// Assert: 期望抛出 ArgumentNullException
// Arrange, Act & Assert
Assert.ThrowsExactly<ArgumentNullException>(() => _keyedList.CopyTo(null!, 0));
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void CopyTo_NegativeArrayIndex_ThrowsArgumentOutOfRangeException()
{
// Arrange
var array = new TestItem[_keyedList.Count];

// Act
_keyedList.CopyTo(array, -1);

// Assert: 期望抛出 ArgumentOutOfRangeException
// Act & Assert
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList.CopyTo(array, -1));
}

[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void CopyTo_InsufficientArraySpace_ThrowsArgumentException()
{
// Arrange
var array = new TestItem[_keyedList.Count - 1];

// Act
_keyedList.CopyTo(array, 0);

// Assert: 期望抛出 ArgumentException
// Act & Assert
Assert.ThrowsExactly<ArgumentException>(() => _keyedList.CopyTo(array, 0));
}

#endregion
Expand Down Expand Up @@ -482,29 +498,23 @@ public void Insert_ValidIndex_InsertsItemAtCorrectPosition()
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Insert_NegativeIndex_ThrowsArgumentOutOfRangeException()
{
// Arrange
var newItem = new TestItem { Id = 4, Name = "Item 4" };

// Act
_keyedList.Insert(-1, newItem);

// Assert: 期望抛出 ArgumentOutOfRangeException
// Act & Assert
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList.Insert(-1, newItem));
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Insert_IndexGreaterThanCount_ThrowsArgumentOutOfRangeException()
{
// Arrange
var newItem = new TestItem { Id = 4, Name = "Item 4" };

// Act
_keyedList.Insert(_keyedList.Count + 1, newItem);

// Assert: 期望抛出 ArgumentOutOfRangeException
// Act & Assert
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList.Insert(_keyedList.Count + 1, newItem));
}

#endregion
Expand Down Expand Up @@ -562,23 +572,17 @@ public void RemoveAt_ValidIndex_RemovesItemAtIndex()
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void RemoveAt_NegativeIndex_ThrowsArgumentOutOfRangeException()
{
// Act
_keyedList.RemoveAt(-1);

// Assert: 期望抛出 ArgumentOutOfRangeException
// Act & Assert
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList.RemoveAt(-1));
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void RemoveAt_IndexEqualToCount_ThrowsArgumentOutOfRangeException()
{
// Act
_keyedList.RemoveAt(_keyedList.Count);

// Assert: 期望抛出 ArgumentOutOfRangeException
// Act & Assert
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => _keyedList.RemoveAt(_keyedList.Count));
}

#endregion
Expand Down
Loading
Loading