Beispiel #1
0
    public void TestAtomicBoolean()
    {
        AtomicBoolean b = new AtomicBoolean();

        Assert.IsFalse(b.Value);
        b = new AtomicBoolean(false);
        Assert.IsFalse(b.Value);
        b = new AtomicBoolean(true);
        Assert.IsTrue(b.Value);
        //when Value is already true, FalseToTrue fails
        b.Value = true;
        Assert.IsFalse(b.FalseToTrue());
        Assert.IsTrue(b.Value);
        //when Value is already false, TrueToFalse fails
        b.Value = false;
        Assert.IsFalse(b.TrueToFalse());
        Assert.IsFalse(b.Value);
        //Value not changed if SetWhen fails
        b.Value = false;
        Assert.IsFalse(b.SetWhen(true, true));
        Assert.IsFalse(b.Value);
        //Value not changed if SetWhen fails
        b.Value = true;
        Assert.IsFalse(b.SetWhen(false, false));
        Assert.IsTrue(b.Value);
    }
Beispiel #2
0
        public NormalResult EnableSendKey(bool enable)
        {
            if (enable == true)
            {
                _sendKeyEnabled.FalseToTrue();
            }
            else
            {
                _sendKeyEnabled.TrueToFalse();
            }

            /*
             * string message = "";
             * if (enable)
             *  message = "SendKey 打开";
             * else
             *  message = "SendKey 关闭";
             * Program.MainForm.OutputHistory(message, 0);
             * Program.MainForm?.Speak(message);
             */

            return(new NormalResult());
        }