public void JsonSerializer() { ExecRun((item) => { var data = _json.SerializeCacheItem(item); var result = _json.DeserializeCacheItem <TestPoco>(data, _pocoType); if (result == null) { throw new Exception(); } }); }
public void JsonSerializer_CacheItemWithPocco() { // arrange var serializer = new JsonCacheSerializer(); var pocco = SerializerPoccoSerializable.Create(); var item = new CacheItem <SerializerPoccoSerializable>("key", "region", pocco, ExpirationMode.Absolute, TimeSpan.FromDays(1)); // act var data = serializer.SerializeCacheItem(item); var result = serializer.DeserializeCacheItem <SerializerPoccoSerializable>(data, pocco.GetType()); result.ShouldBeEquivalentTo(item); }
public void JsonSerializer_CacheItemOfObject_Primitives <T>(T value) { // arrange var serializer = new JsonCacheSerializer(); var item = new CacheItem <object>("key", value); // act var data = serializer.SerializeCacheItem(item); var result = serializer.DeserializeCacheItem <object>(data, typeof(T)); result.Value.Should().Be(value); result.ValueType.Should().Be(item.ValueType); result.CreatedUtc.Should().Be(item.CreatedUtc); result.ExpirationMode.Should().Be(item.ExpirationMode); result.ExpirationTimeout.Should().Be(item.ExpirationTimeout); result.Key.Should().Be(item.Key); result.LastAccessedUtc.Should().Be(item.LastAccessedUtc); result.Region.Should().Be(item.Region); }