Skip to content

Commit dc64d5e

Browse files
test: Bump NUnit from 4.5.1 to 4.6.1 and resolve compiler ambiguities (appium#1077)
* test: Bump NUnit from 4.5.1 to 4.6.1 --- updated-dependencies: - dependency-name: NUnit dependency-version: 4.6.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Resolve NUnit 4.6.1 compiler ambiguities in integration tests * style/refactor: Address review comments on NUnit 4.6.1 fixes * fix: Resolve argument ordering in Espresso element tests and negative timeout in AppTests * perf: Cache Location object in GeolocationTests to avoid redundant remote API calls * Address review comments on GeolocationTests --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent aa0a771 commit dc64d5e

22 files changed

Lines changed: 176 additions & 192 deletions

test/integration/Android/ActionsChainsTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Licensed under the Apache License, Version 2.0 (the "License");
1+
//Licensed under the Apache License, Version 2.0 (the "License");
22
//you may not use this file except in compliance with the License.
33
//See the NOTICE file distributed with this work for additional
44
//information regarding copyright ownership.
@@ -182,11 +182,11 @@ public void ScrollActionTestCase()
182182

183183
_driver.PerformActions(sequenceActions);
184184

185-
Assert.Multiple(() =>
185+
using (Assert.EnterMultipleScope())
186186
{
187187
Assert.That(origin.Location.Y, Is.Not.EqualTo(loc1.Y));
188188
Assert.That(target.Location.Y, Is.Not.EqualTo(loc2.Y));
189-
});
189+
}
190190

191191
}
192192

@@ -243,11 +243,11 @@ public void ScrollUsingAddActionsTestCase()
243243
var sequenceActions = actionBuilder.ToActionSequenceList();
244244
_driver.PerformActions(sequenceActions);
245245

246-
Assert.Multiple(() =>
246+
using (Assert.EnterMultipleScope())
247247
{
248248
Assert.That(origin.Location.Y, Is.Not.EqualTo(loc1.Y));
249249
Assert.That(target.Location.Y, Is.Not.EqualTo(loc2.Y));
250-
});
250+
}
251251

252252
}
253253
}

test/integration/Android/AndroidUiScrollableTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ public void SetSwipeDeadZonePercentageAddsCorrectCallToStatement()
161161
[TestCase(-1)]
162162
public void SetSwipeDeadZonePercentageThrowsExceptionIfOutOfRange(double invalidValue)
163163
{
164-
Assert.Throws<ArgumentOutOfRangeException>(() =>
165-
_sut.SetSwipeDeadZonePercentage(invalidValue));
164+
Assert.Throws<ArgumentOutOfRangeException>((System.Action)(() =>
165+
_sut.SetSwipeDeadZonePercentage(invalidValue)));
166166
}
167167

168168
[Test]

test/integration/Android/App/InstallAppTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void MobileInstallApp_IsIdempotent()
6666
public void MobileInstallApp_InvalidPath_Throws()
6767
{
6868
var badPath = "/nonexistent/path/app.apk";
69-
var ex = Assert.Throws<UnknownErrorException>(() => _driver.InstallApp(badPath));
69+
var ex = Assert.Throws<UnknownErrorException>((System.Action)(() => _driver.InstallApp(badPath)));
7070
Assert.That(ex.Message, Does.Contain("does not exist").IgnoreCase);
7171
}
7272

test/integration/Android/ClipboardTest.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,41 @@ public void OneTimeTearDown()
4646
public void WhenSetClipboardContentTypeIsPlainTextGetClipboardShouldReturnEncodedBase64String()
4747
{
4848
_driver.SetClipboard(ClipboardContentType.PlainText, ClipboardTestString);
49-
Assert.That(() => Regex.IsMatch(_driver.GetClipboard(ClipboardContentType.PlainText), Base64RegexPattern, RegexOptions.Multiline),
50-
Is.True);
49+
Assert.That(Regex.IsMatch(_driver.GetClipboard(ClipboardContentType.PlainText), Base64RegexPattern, RegexOptions.Multiline), Is.True);
5150
}
5251

5352
[Test]
5453
public void WhenClipboardContentTypeIsPlainTextWithLabelGetClipboardTextShouldReturnActualText()
5554
{
5655
_driver.SetClipboardText(ClipboardTestString, label:"testing");
57-
Assert.That(() => _driver.GetClipboardText(), Does.Match(ClipboardTestString));
56+
Assert.That(_driver.GetClipboardText(), Does.Match(ClipboardTestString));
5857
}
5958

6059
[Test]
6160
public void WhenClipboardContentTypeIsPlainTextWithOutLabelGetClipboardTextShouldReturnActualText()
6261
{
6362
_driver.SetClipboardText(ClipboardTestString, null);
64-
Assert.That(() => _driver.GetClipboardText(), Does.Match(ClipboardTestString));
63+
Assert.That(_driver.GetClipboardText(), Does.Match(ClipboardTestString));
6564
}
6665

6766
[Test]
6867
public void WhenClipboardIsEmptyGetClipboardShouldReturnEmptyString()
6968
{
7069
_driver.SetClipboardText(string.Empty, null);
71-
Assert.That(() => _driver.GetClipboard(ClipboardContentType.PlainText), Is.Empty);
70+
Assert.That(_driver.GetClipboard(ClipboardContentType.PlainText), Is.Empty);
7271
}
7372

7473
[Test]
7574
public void WhenClipboardIsEmptyGetClipboardTextShouldReturnEmptyString()
7675
{
7776
_driver.SetClipboardText(string.Empty, null);
78-
Assert.That(() => _driver.GetClipboardText(), Is.Empty);
77+
Assert.That(_driver.GetClipboardText(), Is.Empty);
7978
}
8079

8180
[Test]
8281
public void WhenSetClipboardContentTypeIsImageSetClipboardShouldReturnNotImplementedException()
8382
{
84-
Assert.That(() => _driver.SetClipboard(ClipboardContentType.Image, ClipboardTestString),
85-
Throws.TypeOf<NotImplementedException>());
83+
Assert.That((System.Action)(() => _driver.SetClipboard(ClipboardContentType.Image, ClipboardTestString)), Throws.TypeOf<NotImplementedException>());
8684
}
8785

8886
[Test]
@@ -91,8 +89,7 @@ public void WhenSetClipboardContentTypeIsImageSetClipboardShouldReturnNotImpleme
9189
#endif
9290
public void WhenGetClipboardImageGetClipboardShouldReturnNotImplementedException()
9391
{
94-
Assert.That(() => _driver.GetClipboardImage(),
95-
Throws.TypeOf<NotImplementedException>());
92+
Assert.That((System.Action)(() => _driver.GetClipboardImage()), Throws.TypeOf<NotImplementedException>());
9693
}
9794

9895
[Test]
@@ -105,35 +102,31 @@ public void WhenSetClipboardImageSetClipboardShouldReturnNotImplementedException
105102
Image testImage = new Bitmap(100, 100); // Create a sample image for testing
106103

107104
// Act & Assert
108-
_ = Assert.Throws<NotImplementedException>(() => _driver.SetClipboardImage(testImage));
105+
_ = Assert.Throws<NotImplementedException>((System.Action)(() => _driver.SetClipboardImage(testImage)));
109106
}
110107

111108
[Test]
112109
public void WhenGetClipboardUrlGetClipboardShouldReturnNotImplementedException()
113110
{
114-
Assert.That(() => _driver.GetClipboardUrl(),
115-
Throws.TypeOf<NotImplementedException>());
111+
Assert.That((System.Action)(() => _driver.GetClipboardUrl()), Throws.TypeOf<NotImplementedException>());
116112
}
117113

118114
[Test]
119115
public void WhenSetClipboardContentTypeIsUrlSetClipboardShouldReturnNotImplementedException()
120116
{
121-
Assert.That(() => _driver.SetClipboard(ClipboardContentType.Url, string.Empty),
122-
Throws.TypeOf<NotImplementedException>());
117+
Assert.That((System.Action)(() => _driver.SetClipboard(ClipboardContentType.Url, string.Empty)), Throws.TypeOf<NotImplementedException>());
123118
}
124119

125120
[Test]
126121
public void WhenClipboardContentTypeIsUrlGetClipboardShouldReturnNotImplementedException()
127122
{
128-
Assert.That(() => _driver.GetClipboard(ClipboardContentType.Url),
129-
Throws.TypeOf<NotImplementedException>());
123+
Assert.That((System.Action)(() => _driver.GetClipboard(ClipboardContentType.Url)), Throws.TypeOf<NotImplementedException>());
130124
}
131125

132126
[Test]
133127
public void WhenClipboardContentTypeIsImageGetClipboardShouldReturnNotImplementedException()
134128
{
135-
Assert.That(() => _driver.GetClipboard(ClipboardContentType.Image),
136-
Throws.TypeOf<NotImplementedException>());
129+
Assert.That((System.Action)(() => _driver.GetClipboard(ClipboardContentType.Image)), Throws.TypeOf<NotImplementedException>());
137130
}
138131
}
139132
}

test/integration/Android/Device/App/AppTests.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using Appium.Net.Integration.Tests.helpers;
33
using NUnit.Framework;
44
using OpenQA.Selenium.Appium;
@@ -36,22 +36,22 @@ public void TearDown()
3636
public void CanActivateAppTest()
3737
{
3838
//Activate an app to foreground
39-
Assert.DoesNotThrow(() => _driver.ActivateApp(ApiDemosPackageName));
39+
Assert.DoesNotThrow((System.Action)(() => _driver.ActivateApp(ApiDemosPackageName)));
4040

4141
Assert.That(_driver.GetAppState(ApiDemosPackageName), Is.EqualTo(AppState.RunningInForeground));
4242

4343
//Verify the expected app was activated
44-
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement)));
44+
Assert.DoesNotThrow((System.Action)(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement))));
4545
}
4646

4747
[Test]
4848
public void CanActivateAppWithTimeoutTest()
4949
{
5050
//Activate an app to foreground
51-
Assert.DoesNotThrow(() => _driver.ActivateApp(ApiDemosPackageName, TimeSpan.FromSeconds(20)));
51+
Assert.DoesNotThrow((System.Action)(() => _driver.ActivateApp(ApiDemosPackageName, TimeSpan.FromSeconds(20))));
5252

5353
//Verify the expected app was activated
54-
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement)));
54+
Assert.DoesNotThrow((System.Action)(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement))));
5555
}
5656
[Test]
5757
public void CanActivateAppFromBackgroundTest()
@@ -60,16 +60,15 @@ public void CanActivateAppFromBackgroundTest()
6060
_driver.ActivateApp(ApiDemosPackageName);
6161

6262
//Verify the expected app was activated
63-
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement)));
63+
Assert.DoesNotThrow((System.Action)(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement))));
6464

65-
Assert.DoesNotThrow(() => _driver.BackgroundApp());
65+
Assert.DoesNotThrow((System.Action)(() => _driver.BackgroundApp()));
6666

6767
//Activates Test App to foreground from background
68-
Assert.DoesNotThrow(() => _driver.ActivateApp(ApiDemosPackageName));
68+
Assert.DoesNotThrow((System.Action)(() => _driver.ActivateApp(ApiDemosPackageName)));
6969

7070
//Verify the expected app was activated
71-
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement)));
72-
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement)));
71+
Assert.DoesNotThrow((System.Action)(() => _driver.FindElement(MobileBy.AccessibilityId(ApiDemoElement))));
7372
}
7473

7574
#endregion
@@ -79,22 +78,19 @@ public void CanActivateAppFromBackgroundTest()
7978
[Test]
8079
public void CanBackgroundApp()
8180
{
82-
Assert.DoesNotThrow(
83-
() => _driver.BackgroundApp());
81+
Assert.DoesNotThrow((System.Action)(() => _driver.BackgroundApp()));
8482
}
8583

8684
[Test]
8785
public void CanBackgroundAppForSeconds()
8886
{
89-
Assert.DoesNotThrow(
90-
() => _driver.BackgroundApp(TimeSpan.FromSeconds(5)));
87+
Assert.DoesNotThrow((System.Action)(() => _driver.BackgroundApp(TimeSpan.FromSeconds(5))));
9188
}
9289

9390
[Test]
9491
public void CanBackgroundAppToDeactivationUsingNegativeSecond()
9592
{
96-
Assert.DoesNotThrow(
97-
() => _driver.BackgroundApp(-TimeSpan.FromSeconds(-1)));
93+
Assert.DoesNotThrow((System.Action)(() => _driver.BackgroundApp(TimeSpan.FromSeconds(-1))));
9894
}
9995

10096
#endregion

test/integration/Android/Device/Keys/KeyPressTest.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,31 @@ public void LongPressKeyCodeWithMetastateTest()
6666
[Test]
6767
public void PressKeyCodeKeyEventTest()
6868
{
69-
Assert.Multiple(() =>
69+
using (Assert.EnterMultipleScope())
7070
{
71-
Assert.DoesNotThrow(() => _driver.PressKeyCode(new KeyEvent().WithKeyCode(AndroidKeyCode.Space)
72-
.WithMetaKeyModifier(AndroidKeyMetastate.Meta_Shift_On).WithFlag(AndroidKeyCode.FlagSoftKeyboard)));
73-
Assert.Throws<InvalidOperationException>(() =>
74-
_driver.PressKeyCode(new KeyEvent().WithFlag(AndroidKeyCode.Home)));
75-
Assert.Throws<InvalidOperationException>(() =>
71+
Assert.DoesNotThrow((System.Action)(() => _driver.PressKeyCode(new KeyEvent().WithKeyCode(AndroidKeyCode.Space)
72+
.WithMetaKeyModifier(AndroidKeyMetastate.Meta_Shift_On).WithFlag(AndroidKeyCode.FlagSoftKeyboard))));
73+
Assert.Throws<InvalidOperationException>((System.Action)(() =>
74+
_driver.PressKeyCode(new KeyEvent().WithFlag(AndroidKeyCode.Home))));
75+
Assert.Throws<InvalidOperationException>((System.Action)(() =>
7676
_driver.PressKeyCode(new KeyEvent().WithFlag(AndroidKeyCode.Home)
77-
.WithMetaKeyModifier(AndroidKeyCode.MetaAlt_ON)));
78-
});
77+
.WithMetaKeyModifier(AndroidKeyCode.MetaAlt_ON))));
78+
}
7979
}
8080

8181
[Test]
8282
public void LongPressKeyCodeKeyEventTest()
8383
{
84-
Assert.Multiple(() =>
84+
using (Assert.EnterMultipleScope())
8585
{
86-
Assert.DoesNotThrow(() => _driver.LongPressKeyCode(new KeyEvent().WithKeyCode(AndroidKeyCode.Space)
87-
.WithMetaKeyModifier(AndroidKeyMetastate.Meta_Shift_On).WithFlag(AndroidKeyCode.FlagLongPress)));
88-
Assert.Throws<InvalidOperationException>(() =>
89-
_driver.LongPressKeyCode(new KeyEvent().WithFlag(AndroidKeyCode.Home)));
90-
Assert.Throws<InvalidOperationException>(() =>
86+
Assert.DoesNotThrow((System.Action)(() => _driver.LongPressKeyCode(new KeyEvent().WithKeyCode(AndroidKeyCode.Space)
87+
.WithMetaKeyModifier(AndroidKeyMetastate.Meta_Shift_On).WithFlag(AndroidKeyCode.FlagLongPress))));
88+
Assert.Throws<InvalidOperationException>((System.Action)(() =>
89+
_driver.LongPressKeyCode(new KeyEvent().WithFlag(AndroidKeyCode.Home))));
90+
Assert.Throws<InvalidOperationException>((System.Action)(() =>
9191
_driver.LongPressKeyCode(new KeyEvent().WithFlag(AndroidKeyCode.Home)
92-
.WithMetaKeyModifier(AndroidKeyCode.MetaAlt_ON)));
93-
});
92+
.WithMetaKeyModifier(AndroidKeyCode.MetaAlt_ON))));
93+
}
9494
}
9595
}
9696
}

test/integration/Android/Device/NetworkTests.cs

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using Appium.Net.Integration.Tests.helpers;
33
using NUnit.Framework;
44
using OpenQA.Selenium.Appium;
@@ -41,53 +41,52 @@ public void CanToggleGPSTest()
4141
[Test]
4242
public void CanMakeGsmCallTest()
4343
{
44-
Assert.Multiple(() =>
44+
using (Assert.EnterMultipleScope())
4545
{
46-
Assert.DoesNotThrow(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Call));
47-
Assert.DoesNotThrow(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Accept));
48-
Assert.DoesNotThrow(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Cancel));
49-
Assert.DoesNotThrow(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Hold));
50-
});
46+
Assert.DoesNotThrow((System.Action)(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Call)));
47+
Assert.DoesNotThrow((System.Action)(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Accept)));
48+
Assert.DoesNotThrow((System.Action)(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Cancel)));
49+
Assert.DoesNotThrow((System.Action)(() => _driver.MakeGsmCall("5551234567", GsmCallActions.Hold)));
50+
}
5151
}
5252

5353
[Test]
5454
public void CanSetGsmSignalStrengthTest()
5555
{
56-
Assert.Multiple(() =>
56+
using (Assert.EnterMultipleScope())
5757
{
58-
Assert.DoesNotThrow(() => _driver.SetGsmSignalStrength(GsmSignalStrength.NoneOrUnknown));
59-
Assert.DoesNotThrow(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Poor));
60-
Assert.DoesNotThrow(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Good));
61-
Assert.DoesNotThrow(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Moderate));
62-
Assert.DoesNotThrow(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Great));
63-
});
58+
Assert.DoesNotThrow((System.Action)(() => _driver.SetGsmSignalStrength(GsmSignalStrength.NoneOrUnknown)));
59+
Assert.DoesNotThrow((System.Action)(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Poor)));
60+
Assert.DoesNotThrow((System.Action)(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Good)));
61+
Assert.DoesNotThrow((System.Action)(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Moderate)));
62+
Assert.DoesNotThrow((System.Action)(() => _driver.SetGsmSignalStrength(GsmSignalStrength.Great)));
63+
}
6464
}
6565

6666
[Test]
6767
public void CanSetGsmVoiceStateTest()
6868
{
69-
Assert.Multiple(() =>
70-
{
71-
Assert.DoesNotThrow(() =>
72-
_driver.SetGsmVoice(GsmVoiceState.Unregistered));
73-
Assert.DoesNotThrow(() =>
74-
_driver.SetGsmVoice(GsmVoiceState.Home));
75-
Assert.DoesNotThrow(() =>
76-
_driver.SetGsmVoice(GsmVoiceState.Roaming));
77-
Assert.DoesNotThrow(() =>
78-
_driver.SetGsmVoice(GsmVoiceState.Denied));
79-
Assert.DoesNotThrow(() =>
80-
_driver.SetGsmVoice(GsmVoiceState.Off));
81-
Assert.DoesNotThrow(() =>
82-
_driver.SetGsmVoice(GsmVoiceState.On));
83-
}
84-
);
69+
using (Assert.EnterMultipleScope())
70+
{
71+
Assert.DoesNotThrow((System.Action)(() =>
72+
_driver.SetGsmVoice(GsmVoiceState.Unregistered)));
73+
Assert.DoesNotThrow((System.Action)(() =>
74+
_driver.SetGsmVoice(GsmVoiceState.Home)));
75+
Assert.DoesNotThrow((System.Action)(() =>
76+
_driver.SetGsmVoice(GsmVoiceState.Roaming)));
77+
Assert.DoesNotThrow((System.Action)(() =>
78+
_driver.SetGsmVoice(GsmVoiceState.Denied)));
79+
Assert.DoesNotThrow((System.Action)(() =>
80+
_driver.SetGsmVoice(GsmVoiceState.Off)));
81+
Assert.DoesNotThrow((System.Action)(() =>
82+
_driver.SetGsmVoice(GsmVoiceState.On)));
83+
}
8584
}
8685

8786
[Test]
8887
public void CanSendSmsTest()
8988
{
90-
Assert.DoesNotThrow(() => _driver.SendSms("5551234567", "Hey lol"));
89+
Assert.DoesNotThrow((System.Action)(() => _driver.SendSms("5551234567", "Hey lol")));
9190
}
9291
}
9392
}

0 commit comments

Comments
 (0)