Skip to content

Commit b0248b8

Browse files
authored
Fix warnings in integration tests. (#1420)
1 parent 3c210dd commit b0248b8

File tree

9 files changed

+225
-193
lines changed

9 files changed

+225
-193
lines changed

test/integration/SIPSorcery.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net462;net8.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
7-
<!--<TreatWarningsAsErrors>True</TreatWarningsAsErrors>-->
7+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
88
</PropertyGroup>
99

1010
<ItemGroup>

test/integration/core/SIPDnsUnitTest.cs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public SIPDnsUnitTest(Xunit.Abstractions.ITestOutputHelper output)
3838
/// Tests that an IP address can be resolved when the resolution can only be done via a SRV record.
3939
/// </summary>
4040
[Fact]
41-
public void ResolveHostFromServiceTest()
41+
public async Task ResolveHostFromServiceTest()
4242
{
4343
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
4444
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
4545

4646
CancellationTokenSource cts = new CancellationTokenSource();
4747

48-
var result = SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sipsorcery.com"), false, cts.Token).Result;
48+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sipsorcery.com"), false, cts.Token);
4949

5050
Assert.NotNull(result);
5151

@@ -56,7 +56,7 @@ public void ResolveHostFromServiceTest()
5656
/// Tests that an attempt to lookup the a hostname that's not fully qualified works correctly.
5757
/// </summary>
5858
[Fact]
59-
public void LookupLocalHostnameTest()
59+
public async Task LookupLocalHostnameTest()
6060
{
6161
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
6262
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -71,8 +71,7 @@ public void LookupLocalHostnameTest()
7171
}
7272
else
7373
{
74-
//var result = SIPDNSManager.ResolveSIPService(SIPURI.ParseSIPURIRelaxed(hostname), false);
75-
var result = SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed(hostname), false, cts.Token).Result;
74+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed(hostname), false, cts.Token);
7675

7776
Assert.NotNull(result);
7877

@@ -81,7 +80,7 @@ public void LookupLocalHostnameTest()
8180
}
8281

8382
[Fact]
84-
public void ResolveSIPServiceTest()
83+
public async Task ResolveSIPServiceTest()
8584
{
8685
try
8786
{
@@ -92,8 +91,7 @@ public void ResolveSIPServiceTest()
9291

9392
CancellationTokenSource cts = new CancellationTokenSource();
9493

95-
//var result = SIPDNSManager.ResolveSIPService(SIPURI.ParseSIPURIRelaxed("sip:reg.sip-trunk.telekom.de;transport=tcp"), false);
96-
var result = SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sip:reg.sip-trunk.telekom.de;transport=tcp"), false, cts.Token).Result;
94+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sip:reg.sip-trunk.telekom.de;transport=tcp"), false, cts.Token);
9795

9896
Assert.NotNull(result);
9997
logger.LogDebug("resolved to SIP end point {Result}.", result);
@@ -117,7 +115,7 @@ public void ResolveSIPServiceTest()
117115
/// to be supplied from the in-memory cache.
118116
/// </summary>
119117
[Fact]
120-
public void ResolveNoSRVFromCacheTest()
118+
public async Task ResolveNoSRVFromCacheTest()
121119
{
122120
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
123121
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -126,7 +124,7 @@ public void ResolveNoSRVFromCacheTest()
126124

127125
SIPURI lookupURI = SIPURI.ParseSIPURIRelaxed("sip:sip.sipsorcery.com:5060");
128126
//var result = SIPDNSManager.ResolveSIPService(lookupURI, false);
129-
var result = SIPDns.ResolveAsync(lookupURI, false, cts.Token).Result;
127+
var result = await SIPDns.ResolveAsync(lookupURI, false, cts.Token);
130128
Assert.NotNull(result);
131129

132130
//SIPEndPoint resultEP = result.GetSIPEndPoint();
@@ -157,7 +155,7 @@ public async Task ResolveWithSRVFromCacheTest()
157155

158156
SIPURI lookupURI = SIPURI.ParseSIPURIRelaxed("sip:tel.t-online.de");
159157
//var result = SIPDNSManager.ResolveSIPService(lookupURI, false);
160-
var result = await SIPDns.ResolveAsync(lookupURI, false, cts.Token).ConfigureAwait(false);
158+
var result = await SIPDns.ResolveAsync(lookupURI, false, cts.Token);
161159
Assert.NotNull(result);
162160

163161
//SIPEndPoint resultEP = result.GetSIPEndPoint();
@@ -182,7 +180,7 @@ public async Task ResolveSIPServiceAsyncTest()
182180

183181
CancellationTokenSource cts = new CancellationTokenSource();
184182
//var result = await SIPDNSManager.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sip:reg.sip-trunk.telekom.de;transport=tcp"));
185-
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sip:reg.sip-trunk.telekom.de;transport=tcp"), false, cts.Token).ConfigureAwait(false);
183+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sip:reg.sip-trunk.telekom.de;transport=tcp"), false, cts.Token);
186184

187185
//SIPEndPoint resultEP = result.GetSIPEndPoint();
188186

@@ -195,14 +193,14 @@ public async Task ResolveSIPServiceAsyncTest()
195193
/// Tests that the correct end point is resolved for a known sips URI.
196194
/// </summary>
197195
[Fact]
198-
public void ResolveHostFromSecureSIPURITest()
196+
public async Task ResolveHostFromSecureSIPURITest()
199197
{
200198
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
201199
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
202200

203201
CancellationTokenSource cts = new CancellationTokenSource();
204202

205-
var result = SIPDns.ResolveAsync(new SIPURI(null, "sipsorcery.com", null, SIPSchemesEnum.sips, SIPProtocolsEnum.tls), false, cts.Token).Result;
203+
var result = await SIPDns.ResolveAsync(new SIPURI(null, "sipsorcery.com", null, SIPSchemesEnum.sips, SIPProtocolsEnum.tls), false, cts.Token);
206204

207205
Assert.NotNull(result);
208206
Assert.Equal("67.222.131.147", result.Address.ToString());
@@ -216,13 +214,13 @@ public void ResolveHostFromSecureSIPURITest()
216214
/// Tests that attempting to resolve a non-existent hostname is handled gracefully.
217215
/// </summary>
218216
[Fact]
219-
public void ResolveNonExistentServiceTest()
217+
public async Task ResolveNonExistentServiceTest()
220218
{
221219
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
222220
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
223221

224222
CancellationTokenSource cts = new CancellationTokenSource();
225-
var result = SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sipsorceryx.com"), false, cts.Token).Result;
223+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sipsorceryx.com"), false, cts.Token);
226224

227225
Assert.Equal(SIPEndPoint.Empty, result);
228226
}
@@ -231,7 +229,7 @@ public void ResolveNonExistentServiceTest()
231229
/// Tests that using a non-responding DNS server is handled gracefully.
232230
/// </summary>
233231
[Fact]
234-
public void NonRespondingDNSServerTest()
232+
public async Task NonRespondingDNSServerTest()
235233
{
236234
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
237235
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -251,7 +249,7 @@ public void NonRespondingDNSServerTest()
251249
SIPDns.LookupClient = new LookupClient(clientOptions);
252250

253251
CancellationTokenSource cts = new CancellationTokenSource();
254-
var result = SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sipsorcery.com"), false, cts.Token).Result;
252+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed("sipsorcery.com"), false, cts.Token);
255253

256254
Assert.Equal(SIPEndPoint.Empty, result);
257255
}
@@ -265,7 +263,7 @@ public void NonRespondingDNSServerTest()
265263
/// Tests that a lookup that resolves to a CNAME record works correctly.
266264
/// </summary>
267265
[Fact]
268-
public void LookupCNAMETest()
266+
public async Task LookupCNAMETest()
269267
{
270268
logger.LogDebug("--> {MethodName}", System.Reflection.MethodBase.GetCurrentMethod().Name);
271269
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -274,7 +272,7 @@ public void LookupCNAMETest()
274272

275273
string hostname = "utest.sipsorcery.com";
276274

277-
var result = SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed(hostname), false, cts.Token).Result;
275+
var result = await SIPDns.ResolveAsync(SIPURI.ParseSIPURIRelaxed(hostname), false, cts.Token);
278276

279277
Assert.NotNull(result);
280278

0 commit comments

Comments
 (0)