Пример #1
0
        public void LifeTimeTest()
        {
            var key             = Guid.NewGuid().ToString();
            var someOtherValues = DateTime.Now.ToString("O");

            var obj = new MyOTUO()
            {
                Key             = key,
                SomeOtherValues = someOtherValues
            };

            OTUCContext <MyOTUO> .LifeTime = new TimeSpan(0, 0, 3);
            OTUCContext <MyOTUO> .Current.Add(obj);

            Thread.Sleep(3001);
            var result = OTUCContext <MyOTUO> .Current.Get(key);

            Assert.IsNull(result);
        }
Пример #2
0
        public void SimpleAddAndGet()
        {
            var key             = Guid.NewGuid().ToString();
            var someOtherValues = DateTime.Now.ToString("O");

            var obj = new MyOTUO()
            {
                Key             = key,
                SomeOtherValues = someOtherValues
            };

            OTUCContext <MyOTUO> .Current.Add(obj);

            var result = OTUCContext <MyOTUO> .Current.Get(key);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.SomeOtherValues, obj.SomeOtherValues);
            Assert.AreEqual(result.Key, obj.Key);
        }