Skip to content

Commit 6de983e

Browse files
author
michael.hallett
committed
added a test for ToPascalCase; fixed out of memory exception when using calcellation token; closes #717
1 parent 536129e commit 6de983e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

RestSharp.Tests/RestSharp.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<Compile Include="SampleClasses\Goodreads.cs" />
8484
<Compile Include="SampleClasses\GoogleWeatherWithAttributes.cs" />
8585
<Compile Include="SampleClasses\Struct.cs" />
86+
<Compile Include="StringExtensionTests.cs" />
8687
<Compile Include="XmlAttributeDeserializerTests.cs" />
8788
<Compile Include="CultureChange.cs" />
8889
<Compile Include="JsonTests.cs" />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Globalization;
2+
using NUnit.Framework;
3+
using RestSharp.Extensions;
4+
5+
namespace RestSharp.Tests
6+
{
7+
[TestFixture]
8+
public class StringExtensionTests
9+
{
10+
[Test]
11+
[TestCase("this_is_a_test", true, "ThisIsATest")]
12+
[TestCase("this_is_a_test", false, "This_Is_A_Test")]
13+
public void ToPascalCase(string start, bool removeUnderscores, string finish)
14+
{
15+
string result = start.ToPascalCase(removeUnderscores, CultureInfo.InvariantCulture);
16+
17+
Assert.AreEqual(finish, result);
18+
}
19+
}
20+
}

RestSharp/RestClient.Async.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
using System;
1818
using System.Threading;
19+
1920
#if NET4 || MONODROID || MONOTOUCH || WP8
2021
using System.Threading.Tasks;
2122
#endif
23+
2224
using System.Net;
2325

2426
namespace RestSharp
@@ -287,6 +289,8 @@ public virtual Task<IRestResponse<T>> ExecuteTaskAsync<T>(IRestRequest request,
287289
async.Abort();
288290
taskCompletionSource.TrySetCanceled();
289291
});
292+
293+
taskCompletionSource.Task.ContinueWith(t => t.Dispose(), token);
290294
}
291295
catch (Exception ex)
292296
{
@@ -389,6 +393,8 @@ public virtual Task<IRestResponse> ExecuteTaskAsync(IRestRequest request, Cancel
389393
async.Abort();
390394
taskCompletionSource.TrySetCanceled();
391395
});
396+
397+
taskCompletionSource.Task.ContinueWith(t => t.Dispose(), token);
392398
}
393399
catch (Exception ex)
394400
{

0 commit comments

Comments
 (0)