Skip to content

Add UTs for Command Classes #40

@dfederm

Description

@dfederm

For each command of each command class, write UTs.

For "get"/"report" command pairs, something like:

MockDriver driver = new();
Node node = new Node();
FooCommandClass commandClass = new(node, driver, ...);

ReadOnlySpan<byte> responseData = new[] { ... };
dirver.MockResponse(FooCommand.Get, responseData);

var state = await commandClass.GetAsync();

// Verify the report command's parsing
Assert.AreEqual(someValue, commandClass.State.Something);

// Verify Get command's binary format
Assert.AreEqual(1, driver.SentCommands.Count);
CollectionAssert.AreEqual(new[] { ... }, driver.SentCommands[0]);

"Set" commands would be similar, but without the response part.

Likely interfaces would need to be introduced, for example IDriver so that a MockDriver could be produced for the UT.

CCs needing UTs:

  • Basic
  • Battery
  • BinarySensor
  • BinarySwitch
  • ColorSwitch
  • ManufacturerSpecific
  • MultilevelSensor
  • MultilevelSwitch
  • Notification
  • Powerlevel
  • Version
  • WakeUp
  • ZWavePlusInfo

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructureRelated to infrastructure and development

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions