-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathAdbCommandLineClientTests.cs
More file actions
80 lines (74 loc) · 2.71 KB
/
AdbCommandLineClientTests.cs
File metadata and controls
80 lines (74 loc) · 2.71 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
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using Xunit;
namespace AdvancedSharpAdbClient.Tests
{
/// <summary>
/// Tests the <see cref="AdbCommandLineClient"/> class.
/// </summary>
public partial class AdbCommandLineClientTests
{
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.GetVersion"/> method.
/// </summary>
[Fact]
public void GetVersionTest()
{
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 = commandLine.GetVersion();
Assert.Equal(adbVersion, status.AdbVersion);
Assert.Equal(fileVersion, status.FileVersion);
Assert.Equal(filePath, status.FilePath);
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.GetVersion"/> method.
/// </summary>
[Fact]
public void GetVersionNullTest()
{
DummyAdbCommandLineClient commandLine = new()
{
Version = default
};
_ = Assert.Throws<AdbException>(() => commandLine.GetVersion());
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.GetVersion"/> method.
/// </summary>
[Fact]
public void GetOutdatedVersionTest()
{
DummyAdbCommandLineClient commandLine = new()
{
Version = AdbCommandLineStatus.GetVersionFromOutput(["Android Debug Bridge version 1.0.1"])
};
_ = Assert.Throws<AdbException>(() => commandLine.GetVersion());
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.StartServer"/> method.
/// </summary>
[Fact]
public void StartServerTest()
{
DummyAdbCommandLineClient commandLine = new();
Assert.False(commandLine.ServerStarted);
commandLine.StartServer();
Assert.True(commandLine.ServerStarted);
}
/// <summary>
/// Tests the <see cref="AdbCommandLineClient.ToString()"/> method.
/// </summary>
[Fact]
public void ToStringTest()
{
DummyAdbCommandLineClient commandLine = new();
Assert.Equal($"The {typeof(DummyAdbCommandLineClient)} process with adb command line at '{ServerName}'.", commandLine.ToString());
}
private static string ServerName => OperatingSystem.IsWindows() ? "adb.exe" : "adb";
}
}