/// <summary>
        /// 保存设置
        /// </summary>
        /// <returns></returns>
        private bool SaveSetParams()
        {
            int[] temps = new int[6];
            //判断输入是否正确
            if (!int.TryParse(TextBoxLowTemp.Text.ToString(), out temps[0]) ||
                !int.TryParse(TextBoxHighTemp.Text.ToString(), out temps[1]) ||
                !int.TryParse(TextBoxLowHumi.Text.ToString(), out temps[2]) ||
                !int.TryParse(TextBoxHighHumi.Text.ToString(), out temps[3]) ||
                !int.TryParse(TextBoxLowLight.Text.ToString(), out temps[4]) ||
                !int.TryParse(TextBoxHighLight.Text.ToString(), out temps[5]))
            {
                return(false);
            }

            SetParams pars = new SetParams();

            pars.LowTemp   = temps[0];
            pars.HighTemp  = temps[1];
            pars.LowHumi   = temps[2];
            pars.HighHumi  = temps[3];
            pars.LowLight  = temps[4];
            pars.HighLight = temps[5];

            // 判断区间是否正确
            if ((pars.LowLight > pars.HighLight) ||
                (pars.LowTemp > pars.HighTemp) ||
                (pars.LowHumi > pars.HighHumi))
            {
                return(false);
            }

            DeviceHelper.Instance.SetParams = pars;
            return(true);
        }
示例#2
0
        public void setByNullKey(string key, string value)
        {
            SetParams parametes = new SetParams {
                key = key, value = value
            };
            var response = controller.SetValueByKey(parametes);

            Assert.IsInstanceOf <BadRequestObjectResult>(response);
            Assert.AreEqual($"Invalid key <{key}>", response.Value);
        }
示例#3
0
        public void setValue(string key, string value)
        {
            SetParams parametes = new SetParams {
                key = key, value = value
            };

            controller.SetValueByKey(parametes);

            Assert.AreEqual(value, storage[key]);
        }
示例#4
0
        public void setAndGetValue()
        {
            string    key       = "test key";
            string    value     = "test value";
            SetParams parametes = new SetParams {
                key = key, value = value
            };

            controller.SetValueByKey(parametes);
            var    response    = controller.GetValueByKey(key);
            string resultValue = response?.GetType().GetProperty("value")?.GetValue(response);

            Assert.AreEqual(resultValue, value);
        }
示例#5
0
        public void removeValue()
        {
            string    key       = "test key";
            string    value     = "test value";
            SetParams parametes = new SetParams {
                key = key, value = value
            };

            controller.SetValueByKey(parametes);
            controller.RemoveValueByKey(key);

            var    response    = controller.GetValueByKey(key);
            string actualValue = response?.GetType().GetProperty("value")?.GetValue(response);

            Assert.IsNull(actualValue);
        }
示例#6
0
        public void getAllValues()
        {
            Dictionary <string, string> expectedRows = new Dictionary <string, string>
            {
                ["1"] = "test value1",
                ["2"] = "test value2",
                ["3"] = "test value3",
                ["4"] = null
            };

            foreach (var row in expectedRows)
            {
                SetParams parametes = new SetParams {
                    key = row.Key, value = row.Value
                };
                controller.SetValueByKey(parametes);
            }

            Dictionary <string, string> actualRows = controller.GetAll();

            Assert.AreEqual(actualRows, expectedRows);
        }
示例#7
0
 public static extern int Set(IntPtr device, int cmd, int flags, ref SetParams p);
示例#8
0
 public static extern int Set(IntPtr device, int cmd, int flags, ref SetParams p);