From b000abab8356dbe10e5cb76939e1b8bb44ca6c12 Mon Sep 17 00:00:00 2001 From: OJ Date: Sun, 3 Jul 2011 20:54:55 +1000 Subject: [PATCH] Started work on the non-live Async tests Also did a bit of shuffling around. --- CorrugatedIron.Tests/AsyncMethodTester.cs | 37 +++ .../CorrugatedIron.Tests.csproj | 13 +- CorrugatedIron.Tests/RiakAsyncClientTests.cs | 151 ++++++++++++ .../{Comms => }/RiakClientPingTests.cs | 209 ++++++++--------- .../RiakClientSetBucketPropertiesTests.cs | 216 +++++++++--------- .../{Comms => }/RiakClientTestBase.cs | 102 ++++----- .../{Comms => }/RiakClientTests.cs | 2 +- CorrugatedIron/RiakAsyncClient.cs | 23 +- 8 files changed, 471 insertions(+), 282 deletions(-) create mode 100644 CorrugatedIron.Tests/AsyncMethodTester.cs create mode 100644 CorrugatedIron.Tests/RiakAsyncClientTests.cs rename CorrugatedIron.Tests/{Comms => }/RiakClientPingTests.cs (94%) rename CorrugatedIron.Tests/{Comms => }/RiakClientSetBucketPropertiesTests.cs (95%) rename CorrugatedIron.Tests/{Comms => }/RiakClientTestBase.cs (96%) rename CorrugatedIron.Tests/{Comms => }/RiakClientTests.cs (97%) diff --git a/CorrugatedIron.Tests/AsyncMethodTester.cs b/CorrugatedIron.Tests/AsyncMethodTester.cs new file mode 100644 index 00000000..9ddeda43 --- /dev/null +++ b/CorrugatedIron.Tests/AsyncMethodTester.cs @@ -0,0 +1,37 @@ +using System; +using System.Threading; + +namespace CorrugatedIron.Tests +{ + public class AsyncMethodTester + { + private readonly AutoResetEvent _eventHandle; + private TCallbackResult _result; + + public TCallbackResult Result + { + get + { + _eventHandle.WaitOne(); + return _result; + } + } + + public Action HandleResult + { + get + { + return result => + { + _result = result; + _eventHandle.Set(); + }; + } + } + + public AsyncMethodTester() + { + _eventHandle = new AutoResetEvent(false); + } + } +} diff --git a/CorrugatedIron.Tests/CorrugatedIron.Tests.csproj b/CorrugatedIron.Tests/CorrugatedIron.Tests.csproj index 562c6987..110704ce 100644 --- a/CorrugatedIron.Tests/CorrugatedIron.Tests.csproj +++ b/CorrugatedIron.Tests/CorrugatedIron.Tests.csproj @@ -61,10 +61,12 @@ Properties\VersionInfo.cs - - - - + + + + + + @@ -84,6 +86,9 @@ CorrugatedIron + + +