diff --git a/EasyEplanner.Tests/Editor.Test/ObjectProperty.Test.cs b/EasyEplanner.Tests/Editor.Test/ObjectProperty.Test.cs index c6a738bb..3a37415e 100644 --- a/EasyEplanner.Tests/Editor.Test/ObjectProperty.Test.cs +++ b/EasyEplanner.Tests/Editor.Test/ObjectProperty.Test.cs @@ -259,9 +259,9 @@ public void IsDrawOnEplanPage_EmptyObject_ReturnsFalse() } [Test] - public void GetObjectToDrawOnEplanPage_EmptyObject_ReturnsNull() + public void GetObjectToDrawOnEplanPage_EmptyObject_ReturnEmty() { - Assert.IsNull(GetEmptyProperty().GetObjectToDrawOnEplanPage()); + CollectionAssert.IsEmpty(GetEmptyProperty().GetObjectToDrawOnEplanPage()); } [Test] diff --git a/EasyEplanner.Tests/TechObject.Test/Base.Test/Properties.Test/ActionParameter.Test.cs b/EasyEplanner.Tests/TechObject.Test/Base.Test/Properties.Test/ActionParameter.Test.cs index df24a5de..02d8bfe3 100644 --- a/EasyEplanner.Tests/TechObject.Test/Base.Test/Properties.Test/ActionParameter.Test.cs +++ b/EasyEplanner.Tests/TechObject.Test/Base.Test/Properties.Test/ActionParameter.Test.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Editor; using EplanDevice; using Moq; using NUnit.Framework; @@ -109,5 +110,40 @@ public void ModifyDevName() System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic) .SetValue(null, DeviceManager.GetInstance()); } + + [Test] + public void IsDrawToEplanPage_True() + { + Assert.IsTrue(new ActionParameter("", "").IsDrawOnEplanPage); + } + + public void IsDrawToEplanPage_False() + { + var actionParameter = new ActionParameter("ap", "ap"); + + var dev = new V("OBJ1V1", "+OBJ1-V1", "", 1, "OBJ", 1, ""); + + var deviceManager = Mock.Of(m => + m.GetDeviceByEplanName("OBJ1V1") == dev && + m.GetDeviceIndex("OBJ1V1") == 1 && + m.GetDeviceByIndex(1) == dev); + + typeof(BaseParameter).GetField("deviceManager", + System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic) + .SetValue(null, deviceManager); + + actionParameter.SetNewValue("OBJ1V1"); + var res = actionParameter.GetObjectToDrawOnEplanPage(); + + Assert.Multiple(() => + { + Assert.AreEqual(dev, res.FirstOrDefault().DrawingDevice); + Assert.AreEqual(DrawInfo.Style.GREEN_BOX, res.FirstOrDefault().DrawingStyle); + }); + + typeof(BaseParameter).GetField("deviceManager", + System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic) + .SetValue(null, DeviceManager.GetInstance()); + } } } diff --git a/src/Editor/ObjectProperty.cs b/src/Editor/ObjectProperty.cs index b633d415..c11ba9df 100644 --- a/src/Editor/ObjectProperty.cs +++ b/src/Editor/ObjectProperty.cs @@ -11,7 +11,7 @@ namespace Editor /// public class ObjectProperty : ITreeViewItem, IHelperItem { - public ImageIndexEnum ImageIndex { get; set; } = + public ImageIndexEnum ImageIndex { get; set; } = ImageIndexEnum.NONE; /// Имя свойства. @@ -108,7 +108,7 @@ public virtual string[] DisplayText { if (value.ToString() == defaultValue.ToString()) { - return new string[] { name, + return new string[] { name, StaticHelper.CommonConst.StubForCells }; } else @@ -128,7 +128,7 @@ public virtual string[] EditText provider.NumberDecimalSeparator = "."; double v = (double)value; - return new string[] { "", + return new string[] { "", string.Format( provider, "{0:0.##}", v ) }; } @@ -164,7 +164,7 @@ public virtual bool IsCopyable public virtual object Copy() { - if(IsCopyable) + if (IsCopyable) { return this; } @@ -335,7 +335,7 @@ public bool IsLocalRestrictionUse public virtual bool IsDrawOnEplanPage => false; - public virtual List GetObjectToDrawOnEplanPage() => null; + public virtual List GetObjectToDrawOnEplanPage() => new List() { }; public virtual void GetDisplayObjects(out EplanDevice.DeviceType[] devTypes, out EplanDevice.DeviceSubType[] devSubTypes, out bool displayParameters) diff --git a/src/TechObject/Base/Properties/ActionParameter.cs b/src/TechObject/Base/Properties/ActionParameter.cs index fc33bbc9..65801f11 100644 --- a/src/TechObject/Base/Properties/ActionParameter.cs +++ b/src/TechObject/Base/Properties/ActionParameter.cs @@ -58,7 +58,7 @@ public override bool SetNewValue(string newValue) Parameter = null; // В случае привязки нескольких устройств (с ФСА) оставляем последнее - newValue = newValue.Trim().Split(' ').Last(); + newValue = newValue.Trim().Split(' ').LastOrDefault(); newValue = string.IsNullOrEmpty(newValue) ? "-1" : newValue; return base.SetNewValue(newValue);