public void SetupRegistry() { ABSRegistry.LoadedSegments.Clear(); var newSegment = new RegSegment(); StringItem = new RegString() { Data = "InRegistry" }; IntegerItem = new RegInteger() { Data = 12 }; DecimalItem = new RegDecimal() { Data = 12.3f }; BooleanGroupItem = new RegBooleanGroup(); BooleanGroupItem.SetItem(5, true); BooleanGroupItem.SetItem(6, false); ABSRegistry.LoadedSegments.Add("abc", newSegment); newSegment.AddItem("stringItm", StringItem); newSegment.AddItem("integerItm", IntegerItem); newSegment.AddItem("decimalItm", DecimalItem); newSegment.AddItem("booleanGroupItm", BooleanGroupItem); }
public void RegDecimal() { var item = new RegDecimal(); bool eventRan = false; item.ItemChanged += (s, e) => { Assert.AreEqual(82682.652f, item.Data); eventRan = true; }; item.Data = 82682.652f; Assert.AreEqual(82682.652f, item.Data); Assert.IsTrue(eventRan); }
public void AddItem() { var group = SetupGroup(); var newDec = new RegDecimal() { Data = 9.35f }; group.AddItem("abc/def/xxx", newDec); Assert.AreEqual(group.SubGroups["abc"].SubGroups["def"].SubItems["xxx"], newDec); var res = group.TryAddItem("abc/de/xxx", new RegDecimal()); Assert.AreEqual(AddItemResult.InvalidPath, res); res = group.TryAddItem("abc/def/xxx", new RegDecimal()); Assert.AreEqual(AddItemResult.ItemAlreadyExists, res); }
/// <summary> /// 是否是浮点数 /// </summary> /// <param name="inputData">输入字符串</param> /// <returns></returns> public static bool IsDecimal(string inputData) { Match m = RegDecimal.Match(inputData); return(m.Success); }