Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ await RunPairAsyncTest(
"114514");

/// <summary>
/// Tests the <see cref="AdbClient.PairAsync(DnsEndPoint, string, CancellationToken)"/> method.
/// Tests the <see cref="AdbClientExtensions.PairAsync(IAdbClient, DnsEndPoint, string, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void PairAsyncDnsEndpointTest() =>
Expand Down Expand Up @@ -512,11 +512,11 @@ public async void PairAsyncIPAddressNullTest() =>
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.PairAsync((IPAddress)null, "114514"));

/// <summary>
/// Tests the <see cref="AdbClient.PairAsync(DnsEndPoint, string, CancellationToken)"/> method.
/// Tests the <see cref="AdbClientExtensions.PairAsync(IAdbClient, DnsEndPoint, string, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void PairAsyncDnsEndpointNullTest() =>
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.PairAsync(null, "114514"));
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.PairAsync((DnsEndPoint)null, "114514"));

/// <summary>
/// Tests the <see cref="AdbClientExtensions.PairAsync(IAdbClient, IPEndPoint, string, CancellationToken)"/> method.
Expand All @@ -542,7 +542,7 @@ await RunConnectAsyncTest(
"127.0.0.1:5555");

/// <summary>
/// Tests the <see cref="AdbClient.ConnectAsync(DnsEndPoint, CancellationToken)"/> method.
/// Tests the <see cref="AdbClientExtensions.ConnectAsync(IAdbClient, DnsEndPoint, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void ConnectAsyncDnsEndpointTest() =>
Expand All @@ -560,7 +560,7 @@ await RunConnectAsyncTest(
"127.0.0.1:4321");

/// <summary>
/// Tests the <see cref="AdbClientExtensions.ConnectAsync(IAdbClient, string, int, CancellationToken)"/> method.
/// Tests the <see cref="AdbClient.ConnectAsync(string, int, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void ConnectAsyncHostEndpointTest() =>
Expand All @@ -576,11 +576,11 @@ public async void ConnectAsyncIPAddressNullTest() =>
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.ConnectAsync((IPAddress)null));

/// <summary>
/// Tests the <see cref="AdbClient.ConnectAsync(DnsEndPoint, CancellationToken)"/> method.
/// Tests the <see cref="AdbClientExtensions.ConnectAsync(IAdbClient, DnsEndPoint, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void ConnectAsyncDnsEndpointNullTest() =>
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.ConnectAsync(null));
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.ConnectAsync((DnsEndPoint)null));

/// <summary>
/// Tests the <see cref="AdbClientExtensions.ConnectAsync(IAdbClient, IPEndPoint, CancellationToken)"/> method.
Expand All @@ -590,14 +590,14 @@ public async void ConnectAsyncIPEndpointNullTest() =>
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.ConnectAsync((IPEndPoint)null));

/// <summary>
/// Tests the <see cref="AdbClientExtensions.ConnectAsync(IAdbClient, string, int, CancellationToken)"/> method.
/// Tests the <see cref="AdbClient.ConnectAsync(string, int, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void ConnectAsyncHostEndpointNullTest() =>
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.ConnectAsync((string)null));
_ = await Assert.ThrowsAsync<ArgumentNullException>(() => TestClient.ConnectAsync(null));

/// <summary>
/// Tests the <see cref="AdbClient.DisconnectAsync(DnsEndPoint, CancellationToken)"/> method.
/// Tests the <see cref="AdbClientExtensions.DisconnectAsync(IAdbClient, DnsEndPoint, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void DisconnectAsyncTest()
Expand Down
20 changes: 10 additions & 10 deletions AdvancedSharpAdbClient.Tests/AdbClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public void PairIPAddressTest() =>
"114514");

/// <summary>
/// Tests the <see cref="AdbClient.Pair(DnsEndPoint, string)"/> method.
/// Tests the <see cref="AdbClientExtensions.Pair(IAdbClient, DnsEndPoint, string)"/> method.
/// </summary>
[Fact]
public void PairDnsEndpointTest() =>
Expand Down Expand Up @@ -634,11 +634,11 @@ public void PairIPAddressNullTest() =>
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Pair((IPAddress)null, "114514"));

/// <summary>
/// Tests the <see cref="AdbClient.Pair(DnsEndPoint, string)"/> method.
/// Tests the <see cref="AdbClientExtensions.Pair(IAdbClient, DnsEndPoint, string)"/> method.
/// </summary>
[Fact]
public void PairDnsEndpointNullTest() =>
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Pair(null, "114514"));
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Pair((DnsEndPoint)null, "114514"));

/// <summary>
/// Tests the <see cref="AdbClientExtensions.Pair(IAdbClient, IPEndPoint, string)"/> method.
Expand All @@ -664,7 +664,7 @@ public void ConnectIPAddressTest() =>
"127.0.0.1:5555");

/// <summary>
/// Tests the <see cref="AdbClient.Connect(DnsEndPoint)"/> method.
/// Tests the <see cref="AdbClientExtensions.Connect(IAdbClient, DnsEndPoint)"/> method.
/// </summary>
[Fact]
public void ConnectDnsEndpointTest() =>
Expand All @@ -682,7 +682,7 @@ public void ConnectIPEndpointTest() =>
"127.0.0.1:4321");

/// <summary>
/// Tests the <see cref="AdbClientExtensions.Connect(IAdbClient, string, int)"/> method.
/// Tests the <see cref="AdbClient.Connect(string, int)"/> method.
/// </summary>
[Fact]
public void ConnectHostEndpointTest() =>
Expand All @@ -698,11 +698,11 @@ public void ConnectIPAddressNullTest() =>
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Connect((IPAddress)null));

/// <summary>
/// Tests the <see cref="AdbClient.Connect(DnsEndPoint)"/> method.
/// Tests the <see cref="AdbClientExtensions.Connect(IAdbClient, DnsEndPoint)"/> method.
/// </summary>
[Fact]
public void ConnectDnsEndpointNullTest() =>
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Connect(null));
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Connect((DnsEndPoint)null));

/// <summary>
/// Tests the <see cref="AdbClientExtensions.Connect(IAdbClient, IPEndPoint)"/> method.
Expand All @@ -712,14 +712,14 @@ public void ConnectIPEndpointNullTest() =>
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Connect((IPEndPoint)null));

/// <summary>
/// Tests the <see cref="AdbClientExtensions.Connect(IAdbClient, string, int)"/> method.
/// Tests the <see cref="AdbClient.Connect(string, int)"/> method.
/// </summary>
[Fact]
public void ConnectHostEndpointNullTest() =>
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Connect((string)null));
_ = Assert.Throws<ArgumentNullException>(() => TestClient.Connect(null));

/// <summary>
/// Tests the <see cref="AdbClient.Disconnect(DnsEndPoint)"/> method.
/// Tests the <see cref="AdbClientExtensions.Disconnect(IAdbClient, DnsEndPoint)"/> method.
/// </summary>
[Fact]
public void DisconnectTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ at android.os.Binder.execTransactInternal(Binder.java:1165)
}

/// <summary>
/// Tests the <see cref="DeviceClient.ClickAsync(Point, CancellationToken)"/> method.
/// Tests the <see cref="DeviceClient.ClickAsync(Cords, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void ClickCordsAsyncTest()
Expand Down Expand Up @@ -219,7 +219,7 @@ public async void SwipeAsyncTest()
}

/// <summary>
/// Tests the <see cref="DeviceClient.SwipeAsync(Point, Point, long, CancellationToken)"/> method.
/// Tests the <see cref="DeviceClient.SwipeAsync(Cords, Cords, long, CancellationToken)"/> method.
/// </summary>
[Fact]
public async void SwipePointAsyncTest()
Expand Down Expand Up @@ -355,7 +355,7 @@ public async void FindElementAsyncTest()
Assert.Equal("android.widget.TextView", child.Class);
Assert.Equal("com.bilibili.app.in", child.Package);
Assert.Equal("com.bilibili.app.in:id/header_info_name", child.ResourceID);
Assert.Equal(Rectangle.FromLTRB(45, 889, 427, 973), child.Bounds);
Assert.Equal(Area.FromLTRB(45, 889, 427, 973), child.Bounds);
Assert.Equal(child, element.FindDescendantOrSelf(x => x.Text == "where-where"));
Assert.Equal(2, element.FindDescendants().Where(x => x.Text == "where-where").Count());
}
Expand All @@ -379,7 +379,7 @@ public async void FindElementsAsyncTest()
Assert.Equal(145, childCount);
Element element = elements[0][0][0][0][0][0][0][0][0][2][1][0][0];
Assert.Equal("where-where", element.Text);
Assert.Equal(Rectangle.FromLTRB(45, 889, 427, 973), element.Bounds);
Assert.Equal(Area.FromLTRB(45, 889, 427, 973), element.Bounds);
}

/// <summary>
Expand All @@ -401,7 +401,7 @@ public async void FindAsyncElementsTest()
Assert.Equal(145, childCount);
Element element = elements[0][0][0][0][0][0][0][0][0][2][1][0][0];
Assert.Equal("where-where", element.Text);
Assert.Equal(Rectangle.FromLTRB(45, 889, 427, 973), element.Bounds);
Assert.Equal(Area.FromLTRB(45, 889, 427, 973), element.Bounds);
}

/// <summary>
Expand Down
82 changes: 78 additions & 4 deletions AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public partial class DeviceClientTexts
State = DeviceState.Online
};

/// <summary>
/// Tests the <see cref="DeviceClient(IAdbClient, DeviceData)"/> method.
/// </summary>
[Fact]
public void ConstructorNullTest()
{
Expand All @@ -25,6 +28,77 @@ public void ConstructorNullTest()
_ = Assert.Throws<ArgumentOutOfRangeException>(() => new DeviceClient(Substitute.For<IAdbClient>(), new DeviceData()));
}

/// <summary>
/// Tests the <see cref="DeviceClient.Deconstruct(out IAdbClient, out DeviceData)"/> method.
/// </summary>
[Fact]
public void DeconstructTest()
{
IAdbClient client = Substitute.For<IAdbClient>();
DeviceClient deviceClient = new(client, Device);
(IAdbClient adbClient, DeviceData device) = deviceClient;
Assert.Equal(client, adbClient);
Assert.Equal(Device, device);
}

/// <summary>
/// Tests the <see cref="DeviceClient.Equals(DeviceClient?)"/> method.
/// </summary>
[Fact]
public void EqualityTest()
{
IAdbClient c1 = Substitute.For<IAdbClient>();
IAdbClient c2 = Substitute.For<IAdbClient>();
DeviceData d1 = new() { Serial = "1" };
DeviceData d2 = new() { Serial = "2" };

DeviceClient p1 = new(c1, d1);
DeviceClient p2 = new(c2, d2);
DeviceClient p3 = new(c1, d1);

Assert.True(p1 == p3);
Assert.True(p1 != p2);
Assert.True(p2 != p3);

Assert.True(p1.Equals(p3));
Assert.False(p1.Equals(p2));
Assert.False(p2.Equals(p3));

Assert.True(p1.Equals((object)p3));
Assert.False(p1.Equals((object)p2));
Assert.False(p2.Equals((object)p3));

Assert.Equal(p1.GetHashCode(), p3.GetHashCode());
}

/// <summary>
/// Tests the <see cref="DeviceClient(DeviceClient)"/> method.
/// </summary>
[Fact]
public void CloneTest()
{
IAdbClient client = Substitute.For<IAdbClient>();
IAdbClient newClient = Substitute.For<IAdbClient>();
DeviceData device = new() { Serial = "1" };
DeviceData newDevice = new() { Serial = "2" };

DeviceClient deviceClient = new(client, device);
Assert.Equal(client, deviceClient.AdbClient);
Assert.Equal(device, deviceClient.Device);

deviceClient = deviceClient with { };
Assert.Equal(client, deviceClient.AdbClient);
Assert.Equal(device, deviceClient.Device);

deviceClient = deviceClient with { AdbClient = newClient };
Assert.Equal(newClient, deviceClient.AdbClient);
Assert.Equal(device, deviceClient.Device);

deviceClient = deviceClient with { Device = newDevice };
Assert.Equal(newClient, deviceClient.AdbClient);
Assert.Equal(newDevice, deviceClient.Device);
}

/// <summary>
/// Tests the <see cref="DeviceClient.DumpScreenString()"/> method.
/// </summary>
Expand Down Expand Up @@ -203,7 +277,7 @@ at android.os.Binder.execTransactInternal(Binder.java:1165)
}

/// <summary>
/// Tests the <see cref="DeviceClient.Click(Point)"/> method.
/// Tests the <see cref="DeviceClient.Click(Cords)"/> method.
/// </summary>
[Fact]
public void ClickCordsTest()
Expand Down Expand Up @@ -233,7 +307,7 @@ public void SwipeTest()
}

/// <summary>
/// Tests the <see cref="DeviceClient.Swipe(Point, Point, long)"/> method.
/// Tests the <see cref="DeviceClient.Swipe(Cords, Cords, long)"/> method.
/// </summary>
[Fact]
public void SwipePointTest()
Expand Down Expand Up @@ -369,7 +443,7 @@ public void FindElementTest()
Assert.Equal("android.widget.TextView", child.Class);
Assert.Equal("com.bilibili.app.in", child.Package);
Assert.Equal("com.bilibili.app.in:id/header_info_name", child.ResourceID);
Assert.Equal(Rectangle.FromLTRB(45, 889, 427, 973), child.Bounds);
Assert.Equal(Area.FromLTRB(45, 889, 427, 973), child.Bounds);
Assert.Equal(child, element.FindDescendantOrSelf(x => x.Text == "where-where"));
Assert.Equal(2, element.FindDescendants().Where(x => x.Text == "where-where").Count());
}
Expand All @@ -393,7 +467,7 @@ public void FindElementsTest()
Assert.Equal(145, childCount);
Element element = elements[0][0][0][0][0][0][0][0][0][2][1][0][0];
Assert.Equal("where-where", element.Text);
Assert.Equal(Rectangle.FromLTRB(45, 889, 427, 973), element.Bounds);
Assert.Equal(Area.FromLTRB(45, 889, 427, 973), element.Bounds);
}

/// <summary>
Expand Down
Loading