-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathAdbCommandLineClientTests.Async.cs
More file actions
67 lines (63 loc) · 2.52 KB
/
AdbCommandLineClientTests.Async.cs
File metadata and controls
67 lines (63 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace AdvancedSharpAdbClient.Tests
{
public partial class AdbCommandLineClientTests
{
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.GetVersionAsync(CancellationToken)"/> method.
/// </summary>
[Fact]
public async Task GetVersionAsyncTest()
{
Version adbVersion = new(1, 0, 41);
string fileVersion = "34.0.4-android-tools";
string filePath = "/data/data/com.termux/files/usr/bin/adb";
DummyAdbCommandLineClient commandLine = new()
{
Version = new AdbCommandLineStatus(adbVersion, fileVersion, filePath)
};
AdbCommandLineStatus status = await commandLine.GetVersionAsync(TestContext.Current.CancellationToken);
Assert.Equal(adbVersion, status.AdbVersion);
Assert.Equal(fileVersion, status.FileVersion);
Assert.Equal(filePath, status.FilePath);
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.GetVersionAsync(CancellationToken)"/> method.
/// </summary>
[Fact]
public async Task GetVersionAsyncNullTest()
{
DummyAdbCommandLineClient commandLine = new()
{
Version = default
};
_ = await Assert.ThrowsAsync<AdbException>(() => commandLine.GetVersionAsync(TestContext.Current.CancellationToken));
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.GetVersionAsync(CancellationToken)"/> method.
/// </summary>
[Fact]
public async Task GetOutdatedVersionAsyncTest()
{
DummyAdbCommandLineClient commandLine = new()
{
Version = AdbCommandLineStatus.GetVersionFromOutput(["Android Debug Bridge version 1.0.1"])
};
_ = await Assert.ThrowsAsync<AdbException>(() => commandLine.GetVersionAsync(TestContext.Current.CancellationToken));
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.StartServerAsync(CancellationToken)"/> method.
/// </summary>
[Fact]
public async Task StartServerAsyncTest()
{
DummyAdbCommandLineClient commandLine = new();
Assert.False(commandLine.ServerStarted);
await commandLine.StartServerAsync(TestContext.Current.CancellationToken);
Assert.True(commandLine.ServerStarted);
}
}
}