public void AcquireTest()
        {
            RedisMutex mutex  = new RedisMutex("192.168.56.3", ":)");
            bool       result = mutex.Acquire(10000);

            Assert.IsTrue(result);
            result = mutex.Acquire(10000);
            Assert.IsFalse(result);
            mutex.Release();
            result = mutex.Acquire(10000);
            Assert.IsTrue(result);
        }
Esempio n. 2
0
        public void TestMethod()
        {
            string codeIdentifier     = "f6cf5d7322b3493f99a7fb6bb5cf1924";
            string requestIdentifier1 = "2d92b2d3f0a44ef996130a27dc982866";
            string requestIdentifier2 = "2d92b2d3f0a44ef996130a27dc982867";

            RedisMutex mutex1 = this.BuildMutex(codeIdentifier, requestIdentifier1);
            RedisMutex mutex2 = this.BuildMutex(codeIdentifier, requestIdentifier2);

            TimeSpan alertTime = TimeSpan.FromSeconds(5);

            ExecuteDelayed(alertTime, () =>
            {
                mutex1.Release();
                mutex2.Release();
            });

            string response1 = this.ApplySingle(mutex1, codeIdentifier, requestIdentifier1);
            string response2 = this.ApplySingle(mutex2, codeIdentifier, requestIdentifier2);

            Assert.AreEqual(response1, "{\"result\":true}");
            Assert.AreEqual(response2, "{\"result\":true}");
        }