Skip to content
This repository was archived by the owner on Dec 20, 2022. It is now read-only.

Commit 5db1230

Browse files
committed
添加一个命令行解析的单元测试项。 🍊
1 parent 559be48 commit 5db1230

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

tests/Services/CommandLineTest.cs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
using Xunit;
7+
8+
namespace Zongsoft.Services.Tests
9+
{
10+
public class CommandLineTest
11+
{
12+
[Fact]
13+
public void TestCommandLineParse()
14+
{
15+
Assert.Null(CommandLine.Parse(""));
16+
17+
CommandLine line = null;
18+
19+
//line = CommandLine.Parse("/");
20+
//Assert.NotNull(line);
21+
//Assert.Equal("/", line.Name);
22+
//Assert.Equal("", line.Path);
23+
//Assert.Equal("/", line.FullPath);
24+
25+
//line = CommandLine.Parse(".");
26+
//Assert.NotNull(line);
27+
//Assert.Equal(".", line.Name);
28+
//Assert.Equal("", line.Path);
29+
//Assert.Equal(".", line.FullPath);
30+
31+
//line = CommandLine.Parse("..");
32+
//Assert.NotNull(line);
33+
//Assert.Equal("..", line.Name);
34+
//Assert.Equal("", line.Path);
35+
//Assert.Equal("..", line.FullPath);
36+
37+
line = CommandLine.Parse("send");
38+
Assert.Equal("send", line.Name);
39+
Assert.Equal("", line.Path);
40+
Assert.Equal("send", line.FullPath);
41+
42+
line = CommandLine.Parse("/send");
43+
Assert.Equal("send", line.Name);
44+
Assert.Equal("/", line.Path);
45+
Assert.Equal("/send", line.FullPath);
46+
47+
line = CommandLine.Parse("./send");
48+
Assert.Equal("send", line.Name);
49+
Assert.Equal("", line.Path);
50+
Assert.Equal("send", line.FullPath);
51+
52+
line = CommandLine.Parse("../send");
53+
Assert.Equal("send", line.Name);
54+
Assert.Equal("..", line.Path);
55+
Assert.Equal("../send", line.FullPath);
56+
57+
line = CommandLine.Parse("sms.send");
58+
Assert.Equal("send", line.Name);
59+
Assert.Equal("sms", line.Path);
60+
Assert.Equal("sms/send", line.FullPath);
61+
62+
line = CommandLine.Parse("/sms.send");
63+
Assert.Equal("send", line.Name);
64+
Assert.Equal("/sms", line.Path);
65+
Assert.Equal("/sms/send", line.FullPath);
66+
67+
line = CommandLine.Parse("./sms.send");
68+
Assert.Equal("send", line.Name);
69+
Assert.Equal("sms", line.Path);
70+
Assert.Equal("sms/send", line.FullPath);
71+
72+
line = CommandLine.Parse("../sms.send");
73+
Assert.Equal("send", line.Name);
74+
Assert.Equal("../sms", line.Path);
75+
Assert.Equal("../sms/send", line.FullPath);
76+
77+
}
78+
}
79+
}

tests/Zongsoft.CoreLibrary.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<Compile Include="Runtime\Caching\MemoryCacheTest.cs" />
8989
<Compile Include="Security\CredentialTest.cs" />
9090
<Compile Include="Security\UserTest.cs" />
91+
<Compile Include="Services\CommandLineTest.cs" />
9192
<Compile Include="Services\CommandTreeNodeCollectionTests.cs" />
9293
<Compile Include="Services\ServiceProviderTest.cs" />
9394
</ItemGroup>

0 commit comments

Comments
 (0)