Skip to content

Commit

Permalink
make EchonetObjectSpecification.AllProperties public
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Apr 2, 2024
1 parent 5675025 commit deab785
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ IReadOnlyList<EchonetPropertySpecification> Properties
/// <summary>
/// 仕様上定義済みのプロパティの一覧
/// </summary>
internal IReadOnlyDictionary<byte, EchonetPropertySpecification> AllProperties { get; }
public IReadOnlyDictionary<byte, EchonetPropertySpecification> AllProperties { get; }

/// <summary>
/// 仕様上定義済みのGETプロパティの一覧
Expand Down
10 changes: 1 addition & 9 deletions src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite/EchonetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ public EchonetObject(EchonetObjectSpecification classObject,byte instanceCode)

properties = new();

foreach (var prop in classObject.GetProperties.Values)
{
properties.Add(new(prop));
}
foreach (var prop in classObject.SetProperties.Values)
{
properties.Add(new(prop));
}
foreach (var prop in classObject.AnnoProperties.Values)
foreach (var prop in classObject.AllProperties.Values)
{
properties.Add(new(prop));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,48 @@ namespace Smdn.Net.EchonetLite.Appendix;

[TestFixture]
public class EchonetObjectSpecificationTests {
[Test]
public void AllProperties_NodeProfile()
{
Assert.That(Profiles.NodeProfile.AllProperties.Count, Is.EqualTo(19));

Assert.That(Profiles.NodeProfile.GetProperties.All(static p => Profiles.NodeProfile.AllProperties.Contains(p)), Is.True);
Assert.That(Profiles.NodeProfile.SetProperties.All(static p => Profiles.NodeProfile.AllProperties.Contains(p)), Is.True);
Assert.That(Profiles.NodeProfile.AnnoProperties.All(static p => Profiles.NodeProfile.AllProperties.Contains(p)), Is.True);
}

// 0x0EF0 ノードプロファイル
[TestCase(0x80, true)]
[TestCase(0x82, true)]
[TestCase(0x83, true)]
[TestCase(0x89, true)]
[TestCase(0xBF, true)]
[TestCase(0xD3, true)]
[TestCase(0xD4, true)]
[TestCase(0xD5, true)]
[TestCase(0xD6, true)]
[TestCase(0xD7, true)]
// プロファイルオブジェクトスーパークラス
[TestCase(0x88, true)]
[TestCase(0x8A, true)]
[TestCase(0x8B, true)]
[TestCase(0x8C, true)]
[TestCase(0x8D, true)]
[TestCase(0x8E, true)]
[TestCase(0x9D, true)]
[TestCase(0x9E, true)]
[TestCase(0x9F, true)]
// not defined
[TestCase(0x00, false)]
[TestCase(0xFF, false)]
public void AllProperties_NodeProfile_ByEPC(byte epc, bool expected)
{
Assert.That(Profiles.NodeProfile.AllProperties.TryGetValue(epc, out var p), Is.EqualTo(expected));

if (expected)
Assert.That(p, Is.Not.Null);
}

[Test]
public void GetProperties_NodeProfile()
{
Expand All @@ -26,6 +68,7 @@ public void GetProperties_NodeProfile()
[TestCase(0xBF, true)]
[TestCase(0xD3, true)]
[TestCase(0xD4, true)]
[TestCase(0xD5, false)]
[TestCase(0xD6, true)]
[TestCase(0xD7, true)]
// プロファイルオブジェクトスーパークラス
Expand Down Expand Up @@ -59,6 +102,7 @@ public void SetProperties_NodeProfile()
// 0x0EF0 ノードプロファイル
[TestCase(0x80, true)]
[TestCase(0xBF, true)]
[TestCase(0xD5, false)]
// プロファイルオブジェクトスーパークラス
[TestCase(0x8F, false)]
// not defined
Expand Down

0 comments on commit deab785

Please sign in to comment.