Skip to content

Commit

Permalink
test: remove tests for BinaryFormatterTranscoder
Browse files Browse the repository at this point in the history
  • Loading branch information
cnblogs-dudu committed Feb 14, 2024
1 parent 834c6fe commit c19731e
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions test/MemcachedTest/MemcachedClientTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Enyim.Caching;
using Enyim.Caching.Memcached;
using Enyim.Caching.Memcached.Transcoders;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
Expand All @@ -17,7 +16,7 @@ public abstract class MemcachedClientTest
private static readonly ILog _log = LogManager.GetLogger(typeof(MemcachedClientTest));
public const string TestObjectKey = "Hello_World";

protected virtual MemcachedClient GetClient(MemcachedProtocol protocol = MemcachedProtocol.Binary, bool useBinaryFormatterTranscoder = false)
protected virtual MemcachedClient GetClient(MemcachedProtocol protocol = MemcachedProtocol.Binary)
{
IServiceCollection services = new ServiceCollection();
services.AddEnyimMemcached(options =>
Expand All @@ -26,10 +25,6 @@ protected virtual MemcachedClient GetClient(MemcachedProtocol protocol = Memcach
options.Protocol = protocol;
// options.Transcoder = "MessagePackTranscoder";
});
if (useBinaryFormatterTranscoder)
{
services.AddSingleton<ITranscoder, BinaryFormatterTranscoder>();
}

services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole());

Expand Down Expand Up @@ -66,11 +61,6 @@ public async Task StoreObjectTest()
{
Assert.True(await client.StoreAsync(StoreMode.Set, TestObjectKey, td, DateTime.Now.AddSeconds(5)));
}

using (MemcachedClient client = GetClient(MemcachedProtocol.Binary, true))
{
Assert.True(await client.StoreAsync(StoreMode.Set, TestObjectKey, td, DateTime.Now.AddSeconds(5)));
}
}

[Fact]
Expand All @@ -94,18 +84,6 @@ public void GetObjectTest()
Assert.Equal(19810619, td2.FieldC);
Assert.True(td2.FieldD, "Object was corrupted.");
}

using (MemcachedClient client = GetClient(MemcachedProtocol.Binary, true))
{
Assert.True(client.Store(StoreMode.Set, TestObjectKey, td), "Initialization failed.");
TestData td2 = client.Get<TestData>(TestObjectKey);

Assert.NotNull(td2);
Assert.Equal("Hello", td2.FieldA);
Assert.Equal("World", td2.FieldB);
Assert.Equal(19810619, td2.FieldC);
Assert.True(td2.FieldD, "Object was corrupted.");
}
}

[Fact]
Expand Down

0 comments on commit c19731e

Please sign in to comment.