Permalink
Browse files

Merge remote-tracking branch 'jzablocki/master'

  • Loading branch information...
2 parents b993e33 + e146d2c commit 00dbb3f82ace9a1ae746f271f0b57fee61a4dd81 @enyim enyim committed May 29, 2012
Showing with 13,962 additions and 164 deletions.
  1. +72 −0 Enyim.Caching.Tests/Enyim.Caching.Tests.csproj
  2. +63 −0 Enyim.Caching.Tests/MemcachedClientCasTests.cs
  3. +172 −0 Enyim.Caching.Tests/MemcachedClientConcatTests.cs
  4. +102 −0 Enyim.Caching.Tests/MemcachedClientGetTests.cs
  5. +56 −0 Enyim.Caching.Tests/MemcachedClientMutateTests.cs
  6. +36 −0 Enyim.Caching.Tests/MemcachedClientRemoveTests.cs
  7. +95 −0 Enyim.Caching.Tests/MemcachedClientStoreTests.cs
  8. +149 −0 Enyim.Caching.Tests/MemcachedClientTestsBase.cs
  9. +36 −0 Enyim.Caching.Tests/Properties/AssemblyInfo.cs
  10. +4 −0 Enyim.Caching.Tests/packages.config
  11. +6 −0 Enyim.Caching.sln
  12. +36 −0 Enyim.Caching/Enyim.Caching.csproj
  13. +76 −0 Enyim.Caching/IMemcachedResultsClient.cs
  14. +2 −1 Enyim.Caching/Memcached/IMemcachedNode.cs
  15. +75 −28 Enyim.Caching/Memcached/MemcachedNode.cs
  16. +2 −1 Enyim.Caching/Memcached/OperationInterfaces.cs
  17. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/BinaryNode.cs
  18. +20 −4 Enyim.Caching/Memcached/Protocol/Binary/BinarySingleItemOperation.cs
  19. +3 −2 Enyim.Caching/Memcached/Protocol/Binary/ConcatOperation.cs
  20. +14 −3 Enyim.Caching/Memcached/Protocol/Binary/DeleteOperation.cs
  21. +10 −2 Enyim.Caching/Memcached/Protocol/Binary/FlushOperation.cs
  22. +9 −4 Enyim.Caching/Memcached/Protocol/Binary/GetOperation.cs
  23. +6 −3 Enyim.Caching/Memcached/Protocol/Binary/MultiGetOperation.cs
  24. +9 −4 Enyim.Caching/Memcached/Protocol/Binary/MutatorOperation.cs
  25. +10 −2 Enyim.Caching/Memcached/Protocol/Binary/SaslStep.cs
  26. +10 −2 Enyim.Caching/Memcached/Protocol/Binary/StatsOperation.cs
  27. +15 −4 Enyim.Caching/Memcached/Protocol/Binary/StoreOperation.cs
  28. +3 −2 Enyim.Caching/Memcached/Protocol/Operation.cs
  29. +7 −2 Enyim.Caching/Memcached/Protocol/Text/DeleteOperation.cs
  30. +4 −3 Enyim.Caching/Memcached/Protocol/Text/FlushOperation.cs
  31. +6 −3 Enyim.Caching/Memcached/Protocol/Text/GetOperation.cs
  32. +4 −2 Enyim.Caching/Memcached/Protocol/Text/MultiGetOperation.cs
  33. +8 −3 Enyim.Caching/Memcached/Protocol/Text/MutatorOperation.cs
  34. +4 −2 Enyim.Caching/Memcached/Protocol/Text/StatsOperation.cs
  35. +6 −2 Enyim.Caching/Memcached/Protocol/Text/StoreOperationBase.cs
  36. +34 −0 Enyim.Caching/Memcached/Results/BinaryOperationResult.cs
  37. +34 −0 Enyim.Caching/Memcached/Results/ConcatOperationResult.cs
  38. +83 −0 Enyim.Caching/Memcached/Results/Extensions/OperationResultExtensions.cs
  39. +41 −0 Enyim.Caching/Memcached/Results/Factories/DefaultConcatOperationResultFactory.cs
  40. +42 −0 Enyim.Caching/Memcached/Results/Factories/DefaultGetOperationResultFactory.cs
  41. +42 −0 Enyim.Caching/Memcached/Results/Factories/DefaultGetOperationResultFactory`1.cs
  42. +41 −0 Enyim.Caching/Memcached/Results/Factories/DefaultMutateOperationResultFactory.cs
  43. +41 −0 Enyim.Caching/Memcached/Results/Factories/DefaultRemoveOperationResultFactory.cs
  44. +42 −0 Enyim.Caching/Memcached/Results/Factories/DefaultStoreOperationResultFactory.cs
  45. +34 −0 Enyim.Caching/Memcached/Results/Factories/IConcatOperationResultFactory.cs
  46. +34 −0 Enyim.Caching/Memcached/Results/Factories/IGetOperationResultFactory.cs
  47. +34 −0 Enyim.Caching/Memcached/Results/Factories/IGetOperationResultFactory`1.cs
  48. +34 −0 Enyim.Caching/Memcached/Results/Factories/IMutateOperationResultFactory.cs
  49. +34 −0 Enyim.Caching/Memcached/Results/Factories/IRemoveOperationResultFactory.cs
  50. +34 −0 Enyim.Caching/Memcached/Results/Factories/IStoreOperationResultFactory.cs
  51. +39 −0 Enyim.Caching/Memcached/Results/GetOperationResult.cs
  52. +38 −0 Enyim.Caching/Memcached/Results/GetOperationResult`1.cs
  53. +53 −0 Enyim.Caching/Memcached/Results/Helpers/ResultHelper.cs
  54. +36 −0 Enyim.Caching/Memcached/Results/ICasOperationResult.cs
  55. +33 −0 Enyim.Caching/Memcached/Results/IConcatOperationResult.cs
  56. +34 −0 Enyim.Caching/Memcached/Results/IGetOperationResult`1.cs
  57. +33 −0 Enyim.Caching/Memcached/Results/IGetOperationResults.cs
  58. +34 −0 Enyim.Caching/Memcached/Results/IMutateOperationResult.cs
  59. +39 −0 Enyim.Caching/Memcached/Results/INullableOperationResult`1.cs
  60. +60 −0 Enyim.Caching/Memcached/Results/IOperationResult.cs
  61. +33 −0 Enyim.Caching/Memcached/Results/IPooledSocketResult.cs
  62. +33 −0 Enyim.Caching/Memcached/Results/IRemoveOperationResult.cs
  63. +33 −0 Enyim.Caching/Memcached/Results/IStoreOperationResult.cs
  64. +36 −0 Enyim.Caching/Memcached/Results/MutateOperationResult.cs
  65. +43 −0 Enyim.Caching/Memcached/Results/OperationResultBase.cs
  66. +36 −0 Enyim.Caching/Memcached/Results/PooledSocketResult.cs
  67. +34 −0 Enyim.Caching/Memcached/Results/RemoveOperationResult.cs
  68. +34 −0 Enyim.Caching/Memcached/Results/StoreOperationResult.cs
  69. +33 −0 Enyim.Caching/Memcached/Results/TextOperationResult.cs
  70. +496 −0 Enyim.Caching/MemcachedClient.Results.cs
  71. +153 −84 Enyim.Caching/MemcachedClient.cs
  72. BIN packages/NUnit.2.6.0.12054/NUnit.2.6.0.12054.nupkg
  73. BIN packages/NUnit.2.6.0.12054/lib/nunit.framework.dll
  74. +10,845 −0 packages/NUnit.2.6.0.12054/lib/nunit.framework.xml
  75. +15 −0 packages/NUnit.2.6.0.12054/license.txt
  76. +4 −0 packages/repositories.config
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{5A048FA9-6025-4E06-B3CC-D6F2BEE7DA46}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Enyim.Caching.Tests</RootNamespace>
+ <AssemblyName>Enyim.Caching.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MemcachedClientCasTests.cs" />
+ <Compile Include="MemcachedClientConcatTests.cs" />
+ <Compile Include="MemcachedClientGetTests.cs" />
+ <Compile Include="MemcachedClientMutateTests.cs" />
+ <Compile Include="MemcachedClientRemoveTests.cs" />
+ <Compile Include="MemcachedClientStoreTests.cs" />
+ <Compile Include="MemcachedClientTestsBase.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Enyim.Caching\Enyim.Caching.csproj">
+ <Project>{D438C0B3-A168-40B8-BDDD-61F0939DFF35}</Project>
+ <Name>Enyim.Caching</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using Enyim.Caching.Memcached;
+using Enyim.Caching.Memcached.Results;
+
+namespace Enyim.Caching.Tests
+{
+
+ [TestFixture(Description = "MemcachedClient Store Tests")]
+ public class MemcachedClientCasTests : MemcachedClientTestsBase
+ {
+
+ [Test]
+ public void When_Storing_Item_With_Valid_Cas_Result_Is_Successful()
+ {
+ var key = GetUniqueKey("cas");
+ var value = GetRandomString();
+ var storeResult = Store(StoreMode.Add, key, value);
+ StoreAssertPass(storeResult);
+
+ var casResult = _Client.ExecuteCas(StoreMode.Set, key, value, storeResult.Cas);
+ StoreAssertPass(casResult);
+ }
+
+ [Test]
+ public void When_Storing_Item_With_Invalid_Cas_Result_Is_Not_Successful()
+ {
+ var key = GetUniqueKey("cas");
+ var value = GetRandomString();
+ var storeResult = Store(StoreMode.Add, key, value);
+ StoreAssertPass(storeResult);
+
+ var casResult = _Client.ExecuteCas(StoreMode.Set, key, value, storeResult.Cas - 1);
+ StoreAssertFail(casResult);
+ }
+
+ }
+}
+
+#region [ License information ]
+/* ************************************************************
+ *
+ * @author Couchbase <info@couchbase.com>
+ * @copyright 2012 Couchbase, Inc.
+ * @copyright 2012 Attila Kiskó, enyim.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ************************************************************/
+#endregion
@@ -0,0 +1,172 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+
+namespace Enyim.Caching.Tests
+{
+ [TestFixture]
+ public class MemcachedClientConcatTests : MemcachedClientTestsBase
+ {
+ [Test]
+ public void When_Appending_To_Existing_Value_Result_Is_Successful()
+ {
+ var key = GetUniqueKey("concat");
+ var value = GetRandomString();
+
+ var storeResult = Store(key: key);
+ StoreAssertPass(storeResult);
+
+ var toAppend = "The End";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(toAppend));
+ var concatResult = _Client.ExecuteAppend(key, data);
+ ConcatAssertPass(concatResult);
+
+ var getResult = _Client.ExecuteGet(key);
+ GetAssertPass(getResult, value + toAppend);
+
+ }
+
+ [Test]
+ public void When_Appending_To_Invalid_Key_Result_Is_Not_Successful()
+ {
+ var key = GetUniqueKey("concat");
+
+ var toAppend = "The End";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(toAppend));
+ var concatResult = _Client.ExecuteAppend(key, data);
+ ConcatAssertFail(concatResult);
+
+ var getResult = _Client.ExecuteGet(key);
+ GetAssertFail(getResult);
+
+ }
+
+ [Test]
+ public void When_Prepending_To_Existing_Value_Result_Is_Successful()
+ {
+ var key = GetUniqueKey("concat");
+ var value = GetRandomString();
+
+ var storeResult = Store(key: key);
+ StoreAssertPass(storeResult);
+
+ var toPrepend = "The Beginning";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(toPrepend));
+ var concatResult = _Client.ExecutePrepend(key, data);
+ ConcatAssertPass(concatResult);
+
+ var getResult = _Client.ExecuteGet(key);
+ GetAssertPass(getResult, toPrepend + value);
+
+ }
+
+ [Test]
+ public void When_Prepending_To_Invalid_Key_Result_Is_Not_Successful()
+ {
+ var key = GetUniqueKey("concat");
+
+ var toPrepend = "The End";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(toPrepend));
+ var concatResult = _Client.ExecutePrepend(key, data);
+ ConcatAssertFail(concatResult);
+
+ var getResult = _Client.ExecuteGet(key);
+ GetAssertFail(getResult);
+
+ }
+
+ [Test]
+ public void When_Appending_To_Existing_Value_Result_Is_Successful_With_Valid_Cas()
+ {
+ var key = GetUniqueKey("concat");
+ var value = GetRandomString();
+
+ var storeResult = Store(key: key);
+ StoreAssertPass(storeResult);
+
+ var toAppend = "The End";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(toAppend));
+ var concatResult = _Client.ExecuteAppend(key, storeResult.Cas, data);
+ ConcatAssertPass(concatResult);
+
+ var getResult = _Client.ExecuteGet(key);
+ GetAssertPass(getResult, value + toAppend);
+
+ }
+
+ [Test]
+ public void When_Appending_To_Existing_Value_Result_Is_Not_Successful_With_Invalid_Cas()
+ {
+ var key = GetUniqueKey("concat");
+ var value = GetRandomString();
+
+ var storeResult = Store(key: key);
+ StoreAssertPass(storeResult);
+
+ var toAppend = "The End";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(toAppend));
+ var concatResult = _Client.ExecuteAppend(key, storeResult.Cas - 1, data);
+ ConcatAssertFail(concatResult);
+ }
+
+ [Test]
+ public void When_Prepending_To_Existing_Value_Result_Is_Successful_With_Valid_Cas()
+ {
+ var key = GetUniqueKey("concat");
+ var value = GetRandomString();
+
+ var storeResult = Store(key: key);
+ StoreAssertPass(storeResult);
+
+ var tpPrepend = "The Beginning";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(tpPrepend));
+ var concatResult = _Client.ExecuteAppend(key, storeResult.Cas, data);
+ ConcatAssertPass(concatResult);
+
+ var getResult = _Client.ExecuteGet(key);
+ GetAssertPass(getResult, value + tpPrepend);
+
+ }
+
+ [Test]
+ public void When_Prepending_To_Existing_Value_Result_Is_Not_Successful_With_Invalid_Cas()
+ {
+ var key = GetUniqueKey("concat");
+ var value = GetRandomString();
+
+ var storeResult = Store(key: key);
+ StoreAssertPass(storeResult);
+
+ var tpPrepend = "The Beginning";
+ var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(tpPrepend));
+ var concatResult = _Client.ExecuteAppend(key, storeResult.Cas - 1, data);
+ ConcatAssertFail(concatResult);
+
+ }
+
+ }
+}
+
+#region [ License information ]
+/* ************************************************************
+ *
+ * @author Couchbase <info@couchbase.com>
+ * @copyright 2012 Couchbase, Inc.
+ * @copyright 2012 Attila Kiskó, enyim.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ************************************************************/
+#endregion
Oops, something went wrong.

0 comments on commit 00dbb3f

Please sign in to comment.