public void TestEmpty()
        {
            var data = new IgniteSessionStateStoreData(null, 0);

            Assert.AreEqual(0, data.LockId);
            Assert.AreEqual(0, data.Items.Count);
            Assert.AreEqual(0, data.Timeout);
            Assert.IsNull(data.LockNodeId);
            Assert.IsNull(data.LockTime);
            Assert.IsNull(data.StaticObjects);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionStateLockResult"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public SessionStateLockResult(IBinaryRawReader reader)
        {
            _success = reader.ReadBoolean();

            if (_success)
                _data = new IgniteSessionStateStoreData(reader);

            _lockTime = reader.ReadTimestamp();
            _lockId = reader.ReadLong();

            Debug.Assert(_success ^ (_data == null));
            Debug.Assert(_success ^ (_lockTime != null));
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionStateLockResult"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public SessionStateLockResult(IBinaryRawReader reader)
        {
            _success = reader.ReadBoolean();

            if (_success)
            {
                _data = new IgniteSessionStateStoreData(reader);
            }

            _lockTime = reader.ReadTimestamp();
            _lockId   = reader.ReadLong();

            Debug.Assert(_success ^ (_data == null));
            Debug.Assert(_success ^ (_lockTime != null));
        }
        public void TestData()
        {
            // Modification method is internal.
            var statics = new HttpStaticObjectsCollection();
            statics.GetType().GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic)
                .Invoke(statics, new object[] { "int", typeof(int), false });

            var data = new IgniteSessionStateStoreData(statics, 44);

            data.Items["key"] = "val";

            Assert.AreEqual(44, data.Timeout);
            Assert.AreEqual(1, data.StaticObjects.Count);
            Assert.AreEqual(0, data.StaticObjects["int"]);
            Assert.AreEqual("val", data.Items["key"]);
        }
        public void TestSerialization()
        {
            var data = new IgniteSessionStateStoreData(null, 96)
            {
                Timeout = 97,
                LockId = 11,
                LockNodeId = Guid.NewGuid(),
                LockTime = DateTime.UtcNow.AddHours(-1),
            };

            data.Items["key1"] = 1;
            data.Items["key2"] = 2;

            var data0 = SerializeDeserialize(data);

            Assert.AreEqual(data.Timeout, data0.Timeout);
            Assert.AreEqual(data.LockId, data0.LockId);
            Assert.AreEqual(data.LockNodeId, data0.LockNodeId);
            Assert.AreEqual(data.LockTime, data0.LockTime);
            Assert.AreEqual(data.Items.Keys, data0.Items.Keys);
        }
        /// <summary>
        /// Serializes and deserializes back an instance.
        /// </summary>
        private static IgniteSessionStateStoreData SerializeDeserialize(IgniteSessionStateStoreData data)
        {
            var marsh = BinaryUtils.Marshaller;

            using (var stream = new BinaryHeapStream(128))
            {
                var writer = marsh.StartMarshal(stream);

                data.WriteBinary(writer.GetRawWriter(), false);

                stream.Seek(0, SeekOrigin.Begin);

                return new IgniteSessionStateStoreData(marsh.StartUnmarshal(stream));
            }
        }