Skip to content

Commit c1764a2

Browse files
committed
Add tests for DeviceExtensions
1 parent d3a38e6 commit c1764a2

27 files changed

+392
-122
lines changed

AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async void GetDevicesAsyncTest()
8383
[Fact]
8484
public async void CreateForwardAsyncTest() =>
8585
await RunCreateForwardAsyncTest(
86-
(device) => TestClient.CreateForwardAsync(device, "tcp:1", "tcp:2", true),
86+
device => TestClient.CreateForwardAsync(device, "tcp:1", "tcp:2", true),
8787
"tcp:1;tcp:2");
8888

8989
/// <summary>
@@ -92,7 +92,7 @@ await RunCreateForwardAsyncTest(
9292
[Fact]
9393
public async void CreateReverseAsyncTest() =>
9494
await RunCreateReverseAsyncTest(
95-
(device) => TestClient.CreateReverseForwardAsync(device, "tcp:1", "tcp:2", true),
95+
device => TestClient.CreateReverseForwardAsync(device, "tcp:1", "tcp:2", true),
9696
"tcp:1;tcp:2");
9797

9898
/// <summary>
@@ -101,7 +101,7 @@ await RunCreateReverseAsyncTest(
101101
[Fact]
102102
public async void CreateTcpForwardAsyncTest() =>
103103
await RunCreateForwardAsyncTest(
104-
(device) => TestClient.CreateForwardAsync(device, 3, 4),
104+
device => TestClient.CreateForwardAsync(device, 3, 4),
105105
"tcp:3;tcp:4");
106106

107107
/// <summary>
@@ -110,7 +110,7 @@ await RunCreateForwardAsyncTest(
110110
[Fact]
111111
public async void CreateSocketForwardAsyncTest() =>
112112
await RunCreateForwardAsyncTest(
113-
(device) => TestClient.CreateForwardAsync(device, 5, "/socket/1"),
113+
device => TestClient.CreateForwardAsync(device, 5, "/socket/1"),
114114
"tcp:5;local:/socket/1");
115115

116116
/// <summary>

AdvancedSharpAdbClient.Tests/AdbClientTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void SetDeviceOtherException()
192192
[Fact]
193193
public void CreateForwardTest() =>
194194
RunCreateForwardTest(
195-
(device) => TestClient.CreateForward(device, "tcp:1", "tcp:2", true),
195+
device => TestClient.CreateForward(device, "tcp:1", "tcp:2", true),
196196
"tcp:1;tcp:2");
197197

198198
/// <summary>
@@ -201,7 +201,7 @@ public void CreateForwardTest() =>
201201
[Fact]
202202
public void CreateReverseTest() =>
203203
RunCreateReverseTest(
204-
(device) => TestClient.CreateReverseForward(device, "tcp:1", "tcp:2", true),
204+
device => TestClient.CreateReverseForward(device, "tcp:1", "tcp:2", true),
205205
"tcp:1;tcp:2");
206206

207207
/// <summary>
@@ -210,7 +210,7 @@ public void CreateReverseTest() =>
210210
[Fact]
211211
public void CreateTcpForwardTest() =>
212212
RunCreateForwardTest(
213-
(device) => TestClient.CreateForward(device, 3, 4),
213+
device => TestClient.CreateForward(device, 3, 4),
214214
"tcp:3;tcp:4");
215215

216216
/// <summary>
@@ -219,7 +219,7 @@ public void CreateTcpForwardTest() =>
219219
[Fact]
220220
public void CreateSocketForwardTest() =>
221221
RunCreateForwardTest(
222-
(device) => TestClient.CreateForward(device, 5, "/socket/1"),
222+
device => TestClient.CreateForward(device, 5, "/socket/1"),
223223
"tcp:5;local:/socket/1");
224224

225225
/// <summary>

AdvancedSharpAdbClient.Tests/AdbServerTests.Async.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public async void GetStatusAsyncNotRunningTest()
1818
IAdbSocket adbSocketMock = Substitute.For<IAdbSocket>();
1919
adbSocketMock.SendAdbRequestAsync("host:version", Arg.Any<CancellationToken>()).Throws(new AggregateException(new SocketException(AdbServer.ConnectionRefused)));
2020

21-
AdbServer adbServer = new((endPoint) => adbSocketMock, adbCommandLineClientFactory);
21+
AdbServer adbServer = new(endPoint => adbSocketMock, adbCommandLineClientFactory);
2222

2323
AdbServerStatus status = await adbServer.GetStatusAsync();
2424
Assert.False(status.IsRunning);
@@ -51,7 +51,7 @@ public async void GetStatusAsyncRunningTest()
5151
[Fact]
5252
public async void GetStatusAsyncOtherSocketExceptionTest()
5353
{
54-
adbSocketFactory = (endPoint) => throw new SocketException();
54+
adbSocketFactory = endPoint => throw new SocketException();
5555

5656
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
5757

@@ -64,7 +64,7 @@ public async void GetStatusAsyncOtherSocketExceptionTest()
6464
[Fact]
6565
public async void GetStatusAsyncOtherExceptionTest()
6666
{
67-
adbSocketFactory = (endPoint) => throw new Exception();
67+
adbSocketFactory = endPoint => throw new Exception();
6868

6969
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
7070

@@ -107,7 +107,7 @@ public async void StartServerAsyncOutdatedRunningNoExecutableTest()
107107
[Fact]
108108
public async void StartServerAsyncNotRunningNoExecutableTest()
109109
{
110-
adbSocketFactory = (endPoint) => throw new SocketException(AdbServer.ConnectionRefused);
110+
adbSocketFactory = endPoint => throw new SocketException(AdbServer.ConnectionRefused);
111111

112112
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
113113

@@ -141,7 +141,7 @@ public async void StartServerAsyncOutdatedRunningTest()
141141
[Fact]
142142
public async void StartServerAsyncNotRunningTest()
143143
{
144-
adbSocketFactory = (endPoint) => throw new SocketException(AdbServer.ConnectionRefused);
144+
adbSocketFactory = endPoint => throw new SocketException(AdbServer.ConnectionRefused);
145145

146146
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
147147

AdvancedSharpAdbClient.Tests/AdbServerTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public partial class AdbServerTests
2121
public AdbServerTests()
2222
{
2323
socket = new DummyAdbSocket();
24-
adbSocketFactory = (endPoint) => socket;
24+
adbSocketFactory = endPoint => socket;
2525

2626
commandLineClient = new DummyAdbCommandLineClient();
27-
adbCommandLineClientFactory = (version) => commandLineClient;
27+
adbCommandLineClientFactory = version => commandLineClient;
2828

2929
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
3030
}
@@ -38,7 +38,7 @@ public void GetStatusNotRunningTest()
3838
IAdbSocket adbSocketMock = Substitute.For<IAdbSocket>();
3939
adbSocketMock.When(x => x.SendAdbRequest("host:version")).Do(x => throw new SocketException(AdbServer.ConnectionRefused));
4040

41-
AdbServer adbServer = new((endPoint) => adbSocketMock, adbCommandLineClientFactory);
41+
AdbServer adbServer = new(endPoint => adbSocketMock, adbCommandLineClientFactory);
4242

4343
AdbServerStatus status = adbServer.GetStatus();
4444
Assert.False(status.IsRunning);
@@ -71,7 +71,7 @@ public void GetStatusRunningTest()
7171
[Fact]
7272
public void GetStatusOtherSocketExceptionTest()
7373
{
74-
adbSocketFactory = (endPoint) => throw new SocketException();
74+
adbSocketFactory = endPoint => throw new SocketException();
7575

7676
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
7777

@@ -84,7 +84,7 @@ public void GetStatusOtherSocketExceptionTest()
8484
[Fact]
8585
public void GetStatusOtherExceptionTest()
8686
{
87-
adbSocketFactory = (endPoint) => throw new Exception();
87+
adbSocketFactory = endPoint => throw new Exception();
8888

8989
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
9090

@@ -127,7 +127,7 @@ public void StartServerOutdatedRunningNoExecutableTest()
127127
[Fact]
128128
public void StartServerNotRunningNoExecutableTest()
129129
{
130-
adbSocketFactory = (endPoint) => throw new SocketException(AdbServer.ConnectionRefused);
130+
adbSocketFactory = endPoint => throw new SocketException(AdbServer.ConnectionRefused);
131131

132132
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
133133

@@ -161,7 +161,7 @@ public void StartServerOutdatedRunningTest()
161161
[Fact]
162162
public void StartServerNotRunningTest()
163163
{
164-
adbSocketFactory = (endPoint) => throw new SocketException(AdbServer.ConnectionRefused);
164+
adbSocketFactory = endPoint => throw new SocketException(AdbServer.ConnectionRefused);
165165

166166
adbServer = new AdbServer(adbSocketFactory, adbCommandLineClientFactory);
167167

AdvancedSharpAdbClient.Tests/AdbSocketTests.Async.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class AdbSocketTests
1515
[Fact]
1616
public async void SendSyncDATARequestAsyncTest() =>
1717
await RunTestAsync(
18-
(socket) => socket.SendSyncRequestAsync(SyncCommand.DATA, 2, default),
18+
socket => socket.SendSyncRequestAsync(SyncCommand.DATA, 2, default),
1919
[(byte)'D', (byte)'A', (byte)'T', (byte)'A', 2, 0, 0, 0]);
2020

2121
/// <summary>
@@ -24,7 +24,7 @@ await RunTestAsync(
2424
[Fact]
2525
public async void SendSyncSENDRequestAsyncTest() =>
2626
await RunTestAsync(
27-
(socket) => socket.SendSyncRequestAsync(SyncCommand.SEND, "/test", default),
27+
socket => socket.SendSyncRequestAsync(SyncCommand.SEND, "/test", default),
2828
[(byte)'S', (byte)'E', (byte)'N', (byte)'D', 5, 0, 0, 0, (byte)'/', (byte)'t', (byte)'e', (byte)'s', (byte)'t']);
2929

3030
/// <summary>
@@ -33,15 +33,16 @@ await RunTestAsync(
3333
[Fact]
3434
public async void SendSyncDENTRequestAsyncTest() =>
3535
await RunTestAsync(
36-
(socket) => socket.SendSyncRequestAsync(SyncCommand.DENT, "/data", 633, default),
36+
socket => socket.SendSyncRequestAsync(SyncCommand.DENT, "/data", 633, default),
3737
[(byte)'D', (byte)'E', (byte)'N', (byte)'T', 9, 0, 0, 0, (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)',', (byte)'6', (byte)'3', (byte)'3']);
3838

3939
/// <summary>
4040
/// Tests the <see cref="AdbSocket.SendSyncRequestAsync(SyncCommand, string, CancellationToken)"/> method.
4141
/// </summary>
4242
[Fact]
4343
public async void SendSyncNullRequestAsyncTest() =>
44-
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => RunTestAsync((socket) => socket.SendSyncRequestAsync(SyncCommand.DATA, null, default), []));
44+
_ = await Assert.ThrowsAsync<ArgumentNullException>(() =>
45+
RunTestAsync(socket => socket.SendSyncRequestAsync(SyncCommand.DATA, null, default), []));
4546

4647
/// <summary>
4748
/// Tests the <see cref="AdbSocket.ReadSyncResponseAsync(CancellationToken)"/> method.
@@ -218,7 +219,7 @@ public async void ReadAsyncMemoryTest()
218219
[Fact]
219220
public async void SendAdbRequestAsyncTest() =>
220221
await RunTestAsync(
221-
(socket) => socket.SendAdbRequestAsync("Test", default),
222+
socket => socket.SendAdbRequestAsync("Test", default),
222223
"0004Test"u8.ToArray());
223224

224225
private static async Task RunTestAsync(Func<IAdbSocket, Task> test, byte[] expectedDataSent)

AdvancedSharpAdbClient.Tests/AdbSocketTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void IsOkayTest()
6060
[Fact]
6161
public void SendSyncDATARequestTest() =>
6262
RunTest(
63-
(socket) => socket.SendSyncRequest(SyncCommand.DATA, 2),
63+
socket => socket.SendSyncRequest(SyncCommand.DATA, 2),
6464
[(byte)'D', (byte)'A', (byte)'T', (byte)'A', 2, 0, 0, 0]);
6565

6666
/// <summary>
@@ -69,7 +69,7 @@ public void SendSyncDATARequestTest() =>
6969
[Fact]
7070
public void SendSyncSENDRequestTest() =>
7171
RunTest(
72-
(socket) => socket.SendSyncRequest(SyncCommand.SEND, "/test"),
72+
socket => socket.SendSyncRequest(SyncCommand.SEND, "/test"),
7373
[(byte)'S', (byte)'E', (byte)'N', (byte)'D', 5, 0, 0, 0, (byte)'/', (byte)'t', (byte)'e', (byte)'s', (byte)'t']);
7474

7575
/// <summary>
@@ -78,15 +78,16 @@ public void SendSyncSENDRequestTest() =>
7878
[Fact]
7979
public void SendSyncDENTRequestTest() =>
8080
RunTest(
81-
(socket) => socket.SendSyncRequest(SyncCommand.DENT, "/data", 633),
81+
socket => socket.SendSyncRequest(SyncCommand.DENT, "/data", 633),
8282
[(byte)'D', (byte)'E', (byte)'N', (byte)'T', 9, 0, 0, 0, (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)',', (byte)'6', (byte)'3', (byte)'3']);
8383

8484
/// <summary>
8585
/// Tests the <see cref="AdbSocket.SendSyncRequest(SyncCommand, string)"/> method.
8686
/// </summary>
8787
[Fact]
8888
public void SendSyncNullRequestTest() =>
89-
_ = Assert.Throws<ArgumentNullException>(() => RunTest((socket) => socket.SendSyncRequest(SyncCommand.DATA, null), []));
89+
_ = Assert.Throws<ArgumentNullException>(() =>
90+
RunTest(socket => socket.SendSyncRequest(SyncCommand.DATA, null), []));
9091

9192
/// <summary>
9293
/// Tests the <see cref="AdbSocket.ReadSyncResponse"/> method.
@@ -263,7 +264,7 @@ public void ReadSpanTest()
263264
[Fact]
264265
public void SendAdbRequestTest() =>
265266
RunTest(
266-
(socket) => socket.SendAdbRequest("Test"),
267+
socket => socket.SendAdbRequest("Test"),
267268
"0004Test"u8.ToArray());
268269

269270
/// <summary>

0 commit comments

Comments
 (0)