Skip to content

Commit

Permalink
v3.1.2024.1004
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Oct 4, 2024
1 parent 2b0afa9 commit 6480701
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 218 deletions.
3 changes: 3 additions & 0 deletions ClientTest/DiagnosticTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using Stardust.Monitors;
using Xunit;

// 所有测试用例放入一个汇编级集合,除非单独指定Collection特性
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]

namespace ClientTest;

[TestCaseOrderer("NewLife.UnitTest.DefaultOrderer", "NewLife.UnitTest")]
Expand Down
26 changes: 10 additions & 16 deletions ClientTest/LocalStarClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Stardust;
using Stardust;
using Xunit;

namespace ClientTest
namespace ClientTest;

public class LocalStarClientTests
{
public class LocalStarClientTests
[Fact]
public void Info()
{
[Fact]
public void Info()
{
var client = new LocalStarClient();
var inf = client.GetInfo();
var client = new LocalStarClient();
var inf = client.GetInfo();

Assert.NotNull(inf);
Assert.NotEmpty(inf.Server);
}
Assert.NotNull(inf);
Assert.NotEmpty(inf.Server);
}
}
2 changes: 1 addition & 1 deletion ClientTest/StarClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void GetLoginInfoTest()
Assert.NotNull(inf.Node);

Assert.Equal(client.Code, inf.Code);
Assert.Equal(client.Secret.MD5(), inf.Secret);
Assert.Equal(client.Secret, inf.Secret);

var node = client.GetNodeInfo();
var mi = MachineInfo.Current;
Expand Down
8 changes: 2 additions & 6 deletions ClientTest/StarFactoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using NewLife;
using System.Threading.Tasks;
using NewLife.Configuration;
using NewLife.Http;
using NewLife.Log;
using NewLife.Model;
using NewLife.Reflection;
using NewLife.Remoting;
using NewLife.Security;
using Stardust;
Expand Down Expand Up @@ -114,7 +110,7 @@ public async Task SendNodeCommand()
{
using var star = new StarFactory("http://127.0.0.1:6600", "StarWeb", "xxx");

var rs = await star.SendNodeCommand("7F0F011A", "hello", "stone", 33);
var rs = await star.SendNodeCommand("81AFCC68", "hello", "stone", 33);
Assert.True(rs > 0);
}
}
144 changes: 0 additions & 144 deletions StarGateway/Http/HttpRequest.cs

This file was deleted.

8 changes: 0 additions & 8 deletions StarGateway/StarGateway.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,9 @@
<Optimize>false</Optimize>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Http\HttpRequest.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Stardust.Data\Stardust.Data.csproj" />
<ProjectReference Include="..\Stardust\Stardust.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Http\" />
</ItemGroup>

</Project>
85 changes: 42 additions & 43 deletions Stardust.ServerTests/Controllers/ApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,56 @@
using NewLife.Remoting;
using Xunit;

namespace Stardust.Server.Controllers.Tests
namespace Stardust.Server.Controllers.Tests;

public class ApiTests
{
public class ApiTests
{
private readonly TestServer _server;
private readonly TestServer _server;

public ApiTests()
{
_server = new TestServer(WebHost.CreateDefaultBuilder()
.UseStartup<Startup>());
}
public ApiTests()
{
_server = new TestServer(WebHost.CreateDefaultBuilder()
.UseStartup<Startup>());
}

[Theory(DisplayName = "基础测试")]
[InlineData("abcdef")]
[InlineData(null)]
public async Task BasicTest(String state)
{
var client = _server.CreateClient();
[Theory(DisplayName = "基础测试")]
[InlineData("abcdef")]
[InlineData(null)]
public async Task BasicTest(String state)
{
var client = _server.CreateClient();

var response = await client.GetAsync<HttpResponseMessage>("api", new { state });
response.EnsureSuccessStatusCode();
Assert.Equal("application/json", response.Content.Headers.ContentType + "");
var response = await client.GetAsync<HttpResponseMessage>("api", new { state });
response.EnsureSuccessStatusCode();
Assert.Equal("application/json", response.Content.Headers.ContentType + "");

var rs = await client.GetAsync<IDictionary<String, Object>>("api", new { state });
Assert.Null(rs["state"]);
}
var rs = await client.GetAsync<IDictionary<String, Object>>("api", new { state });
Assert.Null(rs["state"]);
}

[Theory(DisplayName = "信息测试")]
[InlineData("abcdef")]
[InlineData(null)]
public async Task InfoTest(String state)
{
var client = _server.CreateClient();
[Theory(DisplayName = "信息测试")]
[InlineData("abcdef")]
[InlineData(null)]
public async Task InfoTest(String state)
{
var client = _server.CreateClient();

var rs = await client.GetAsync<IDictionary<String, Object>>("api/info", new { state });
if (state.IsNullOrEmpty())
Assert.Null(rs["state"]);
else
Assert.NotNull(rs["state"]);
Assert.Equal(state + "", rs["state"] + "");
}
var rs = await client.GetAsync<IDictionary<String, Object>>("api/info", new { state });
if (state.IsNullOrEmpty())
Assert.Null(rs["state"]);
else
Assert.NotNull(rs["state"]);
Assert.Equal(state + "", rs["state"] + "");
}

[Theory(DisplayName = "信息测试2")]
[InlineData("abcdef")]
[InlineData(null)]
public async Task Info2Test(String state)
{
var client = _server.CreateClient();
[Theory(DisplayName = "信息测试2")]
[InlineData("abcdef")]
[InlineData(null)]
public async Task Info2Test(String state)
{
var client = _server.CreateClient();

var rs = await client.PostAsync<Packet>("api/info2", state.ToHex());
Assert.NotNull(rs);
}
var rs = await client.PostAsync<IPacket>("api/info2", state.ToHex());
Assert.NotNull(rs);
}
}

0 comments on commit 6480701

Please sign in to comment.