fix(uns): omit blank optional keys from TagConfig + add omission tests; drop unused ParseInt (T4-T8 review)
This commit is contained in:
@@ -79,4 +79,24 @@ public sealed class AbCipTagConfigModelTests
|
||||
{
|
||||
new AbCipTagConfigModel { TagPath = "Motor1.Status" }.Validate().ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_omits_blank_deviceHostAddress()
|
||||
{
|
||||
var m = new AbCipTagConfigModel { TagPath = "Motor1.Status", DeviceHostAddress = "" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldNotContain("deviceHostAddress");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_includes_deviceHostAddress_when_set()
|
||||
{
|
||||
var m = new AbCipTagConfigModel { TagPath = "Motor1.Status", DeviceHostAddress = "ab://host" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldContain("\"deviceHostAddress\":\"ab://host\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +79,24 @@ public sealed class AbLegacyTagConfigModelTests
|
||||
{
|
||||
new AbLegacyTagConfigModel { Address = "N7:0" }.Validate().ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_omits_blank_deviceHostAddress()
|
||||
{
|
||||
var m = new AbLegacyTagConfigModel { Address = "N7:0", DeviceHostAddress = "" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldNotContain("deviceHostAddress");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_includes_deviceHostAddress_when_set()
|
||||
{
|
||||
var m = new AbLegacyTagConfigModel { Address = "N7:0", DeviceHostAddress = "ab://host" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldContain("\"deviceHostAddress\":\"ab://host\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +79,24 @@ public sealed class FocasTagConfigModelTests
|
||||
{
|
||||
new FocasTagConfigModel { Address = "R100" }.Validate().ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_omits_blank_deviceHostAddress()
|
||||
{
|
||||
var m = new FocasTagConfigModel { Address = "R100", DeviceHostAddress = "" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldNotContain("deviceHostAddress");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_includes_deviceHostAddress_when_set()
|
||||
{
|
||||
var m = new FocasTagConfigModel { Address = "R100", DeviceHostAddress = "ab://host" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldContain("\"deviceHostAddress\":\"ab://host\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ public sealed class TagConfigJsonTests
|
||||
|
||||
TagConfigJson.Set(obj, "region", null);
|
||||
|
||||
TagConfigJson.GetString(obj, "region").ShouldBeNull();
|
||||
obj.ContainsKey("region").ShouldBeFalse();
|
||||
TagConfigJson.Serialize(obj).ShouldNotContain("region");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +79,24 @@ public sealed class TwinCATTagConfigModelTests
|
||||
{
|
||||
new TwinCATTagConfigModel { SymbolPath = "MAIN.bStart" }.Validate().ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_omits_blank_deviceHostAddress()
|
||||
{
|
||||
var m = new TwinCATTagConfigModel { SymbolPath = "MAIN.bStart", DeviceHostAddress = "" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldNotContain("deviceHostAddress");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToJson_includes_deviceHostAddress_when_set()
|
||||
{
|
||||
var m = new TwinCATTagConfigModel { SymbolPath = "MAIN.bStart", DeviceHostAddress = "ab://host" };
|
||||
|
||||
var json = m.ToJson();
|
||||
|
||||
json.ShouldContain("\"deviceHostAddress\":\"ab://host\"");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user