public void AddGraph()
        {
            var order = new Order();
            order.Id = 1;
            order.Person = new Person { Id = 2, Name = "jamir" };

            _cache.Add(order, TimeSpan.FromMinutes(10));

            var retrivedOrder = _cache.Get<Order>(p => p.Id == order.Id);
            var retrivedPerson = _cache.Get<Person>(p => p.Id == order.Person.Id);

            Assert.AreEqual(order.Id, retrivedOrder.Id);
            Assert.IsNotNull(retrivedPerson);
            Assert.AreEqual(order.Person.Id, retrivedPerson.Id);
        }
        public void RemoveGraph_WithNullProperty()
        {
            var order = new Order { Id = 1 };
            _cache.Add(order, TimeSpan.FromMinutes(10));

            _cache.RemoveGraph<Order>(p => p.Id == order.Id);

            Assert.IsFalse(_cache.Contains<Order>(p => p.Id == order.Id));
        }
        public void RemoveGraph()
        {
            var order = new Order();
            order.Id = 1;
            order.Person = new Person { Id = 2, Name = "jamir" };
            _cache.Add(order, TimeSpan.FromMinutes(10));

            _cache.RemoveGraph<Order>(p => p.Id == order.Id);

            Assert.IsFalse(_cache.Contains<Order>(p => p.Id == order.Id));
            Assert.IsFalse(_cache.Contains<Person>(p => p.Id == order.Person.Id));
        }
        public void GetItem_WithChangedCachedProperties()
        {
            var order = new Order();
            order.Id = 1;
            order.Person = new Person { Id = 2, Name = "jamir" };

            _cache.Add(order, TimeSpan.FromMinutes(10));
            _cache.Remove<Person>(p => p.Id == 2);

            var newPerson = new Person { Id = 2, Name = "Marcos" };
            _cache.Add(newPerson, TimeSpan.FromMinutes(10));

            var cachedOrder = _cache.Get<Order>(p => p.Id == 1);

            Assert.AreSame(newPerson, cachedOrder.Person);
        }
        public void AddGraph_WithNullProperty()
        {
            var order = new Order { Id = 1 };

            _cache.Add(order, TimeSpan.FromMinutes(10));

            var retrivedOrder = _cache.Get<Order>(p => p.Id == order.Id);

            Assert.AreSame(order, retrivedOrder);
            Assert.IsNull(order.Person);
        }