public void TestRubTaskInNotLeaderState()
        {
            string lockId = "lockId";

            // ReSharper disable once RedundantArgumentDefaultValue
            // ReSharper disable once RedundantArgumentNameForLiteralExpression
            var lockerMock = new LockerMock(isLeader: false, id: lockId, keeperId: LeaderAwareTaskRunner.GenerateLockKeeperId());
            LeaderAwareTaskRunner runner = new LeaderAwareTaskRunner(lockerMock, lockId);

            runner.RunTaskOnLeader(() => Assert.True(false));
        }
        public void TestRubTaskInNotLeaderState()
        {
            string lockId = "lockId";

            // ReSharper disable once RedundantArgumentDefaultValue
            // ReSharper disable once RedundantArgumentNameForLiteralExpression
            var lockerMock = new LockerMock(isLeader: false, id: lockId, keeperId: LeaderAwareTaskRunner.GenerateLockKeeperId());
            LeaderAwareTaskRunner runner = new LeaderAwareTaskRunner(lockerMock, lockId);

            runner.RunTaskOnLeader(() => Assert.True(false));
        }
        public void TestBecameALeader()
        {
            string lockId = "lockId";

            int i = 0;
            // ReSharper disable once RedundantArgumentDefaultValue
            // ReSharper disable once RedundantArgumentNameForLiteralExpression
            var lockerMock = new LockerMock(isLeader: true, id: lockId, keeperId: LeaderAwareTaskRunner.GenerateLockKeeperId());
            LeaderAwareTaskRunner runner = new LeaderAwareTaskRunner(lockerMock, lockId, 0);
            runner.RunTaskOnLeader(() => i++);
            Thread.Sleep(200);
            lockerMock.IsLeader = false;
            runner.RunTaskOnLeader(() => i++);
            Assert.AreEqual(1, i);
            Thread.Sleep(200);
            lockerMock.IsLeader = true;
            runner.RunTaskOnLeader(() => i++);
            Assert.AreEqual(2, i);
        }
        public void TestBecameALeader()
        {
            string lockId = "lockId";

            int i = 0;
            // ReSharper disable once RedundantArgumentDefaultValue
            // ReSharper disable once RedundantArgumentNameForLiteralExpression
            var lockerMock = new LockerMock(isLeader: true, id: lockId, keeperId: LeaderAwareTaskRunner.GenerateLockKeeperId());
            LeaderAwareTaskRunner runner = new LeaderAwareTaskRunner(lockerMock, lockId, 0);

            runner.RunTaskOnLeader(() => i++);
            Thread.Sleep(200);
            lockerMock.IsLeader = false;
            runner.RunTaskOnLeader(() => i++);
            Assert.AreEqual(1, i);
            Thread.Sleep(200);
            lockerMock.IsLeader = true;
            runner.RunTaskOnLeader(() => i++);
            Assert.AreEqual(2, i);
        }