public void TryGetValue_When_ByteArray_Return_ByteArray()
        {
            var op = new Mock <IOperationResult <Dictionary <string, object> > >(); //value is null

            var bucket = new Mock <IBucket>();

            bucket.Setup(x => x.GetAsync <Dictionary <string, object> >(It.IsAny <string>()))
            .Returns(Task.FromResult(op.Object));

            var provider = new Mock <ICouchbaseCacheBucketProvider>();

            provider.Setup(x => x.GetBucket()).Returns(bucket.Object);

            var cache   = new CouchbaseCache(provider.Object, new CouchbaseCacheOptions());
            var session = new CouchbaseSession(cache, "thesessionkey", new TimeSpan(0, 0, 10, 0), () => true, new LoggerFactory(), true);

            var poco = ConvertToBytes(new Poco {
                Name = "jeff"
            });

            session.Set("Set_Tests", poco);

            byte[] actual;
            var    result = session.TryGetValue("Set_Tests", out actual);

            Assert.True(result);
            Assert.Same(poco, actual);
        }
        public void TryGetValueOfT_Poco_Success()
        {
            var op = new Mock <IOperationResult <Dictionary <string, object> > >(); //value is null

            var bucket = new Mock <IBucket>();

            bucket.Setup(x => x.GetAsync <Dictionary <string, object> >(It.IsAny <string>()))
            .Returns(Task.FromResult(op.Object));

            var provider = new Mock <ICouchbaseCacheBucketProvider>();

            provider.Setup(x => x.GetBucket()).Returns(bucket.Object);

            var cache   = new CouchbaseCache(provider.Object, new CouchbaseCacheOptions());
            var session = new CouchbaseSession(cache, "thesessionkey", new TimeSpan(0, 0, 10, 0), () => true, new LoggerFactory(), true);

            var poco = new Poco {
                Name = "jeff"
            };

            session.Set("thekey", poco);

            Poco value;
            var  result = session.TryGetValue("thekey", out value);

            Assert.True(result);
            Assert.Same(poco, value);
        }
        public void SetOfT_Test()
        {
            var op = new Mock <IOperationResult <Dictionary <string, byte[]> > >(); //value is null

            var bucket = new Mock <IBucket>();

            bucket.Setup(x => x.GetAsync <Dictionary <string, byte[]> >(It.IsAny <string>()))
            .Returns(Task.FromResult(op.Object));

            var provider = new Mock <ICouchbaseCacheBucketProvider>();

            provider.Setup(x => x.GetBucket()).Returns(bucket.Object);

            var cache   = new CouchbaseCache(provider.Object, new CouchbaseCacheOptions());
            var session = new CouchbaseSession(cache, "thesessionkey", new TimeSpan(0, 0, 10, 0), TimeSpan.Zero, () => true, new LoggerFactory(), true);

            var poco = new Poco {
                Name = "jeff"
            };

            session.Set("SetOfT_Tests", poco);

            Poco actual;
            var  result = session.TryGetValue("SetOfT_Tests", out actual);

            Assert.True(result);
            Assert.Equal(poco.Name, actual.Name);
        }
        public void TryGetValue_When_NotFound_Return_Null()
        {
            var op = new Mock <IOperationResult <Dictionary <string, byte[]> > >(); //value is null

            var bucket = new Mock <IBucket>();

            bucket.Setup(x => x.GetAsync <Dictionary <string, byte[]> >(It.IsAny <string>()))
            .Returns(Task.FromResult(op.Object));

            var provider = new Mock <ICouchbaseCacheBucketProvider>();

            provider.Setup(x => x.GetBucket()).Returns(bucket.Object);

            var cache   = new CouchbaseCache(provider.Object, new CouchbaseCacheOptions());
            var session = new CouchbaseSession(cache, "thesessionkey", new TimeSpan(0, 0, 10, 0), TimeSpan.Zero, () => true, new LoggerFactory(), true);

            byte[] actual;
            var    result = session.TryGetValue("Set_Tests", out actual);

            Assert.False(result);
            Assert.Same(null, actual);
        }