Skip to content

Commit 32ac6fe

Browse files
committed
Test Code Improvements
In `Experimental.System.Messaging.Test.csproj`, we upgraded .NET Core 2.0 to .NET 8.0 and updated the test-related package versions to the latest. In `QueueClientTest.cs`, we modified the function to check for the existence of a queue and create one if necessary, ensuring test independence. We also separated the queue path into a variable for improved readability.
1 parent f3830e4 commit 32ac6fe

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Experimental.System.Messaging.Test/Experimental.System.Messaging.Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
12-
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
12+
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

Experimental.System.Messaging.Test/QueueClientTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ public void SendMessage()
2222
[TestMethod]
2323
public void ReceiveMessage()
2424
{
25-
MessageQueue messageQueue = new MessageQueue(".\\Private$\\myQueue");
25+
string path = ".\\Private$\\myQueue";
26+
// Ensure the queue exists to make test independent
27+
if (!MessageQueue.Exists(path))
28+
{
29+
MessageQueue.Create(path);
30+
}
31+
32+
MessageQueue messageQueue = new MessageQueue(path);
2633
messageQueue.Formatter = new XmlMessageFormatter(new Type[1]
2734
{
2835
typeof(Order)

0 commit comments

Comments
 (0)