public void DisposesAllPins() { //arrange var newPin = Substitute.For <Func <byte, IPinInterface> >(); var pin = Substitute.For <IPinInterface>(); newPin.Invoke(Arg.Any <byte>()).Returns(p => pin); var board = new BroadcomBoard(newPin); for (var x = 0; x < 28; x++) { board.GetType().GetProperty($"GPIO{x}").GetValue(board); } //act board.Dispose(); //assert pin.Received(28).Dispose(); }
public void PinsAreMappedCorrectly() { //arrange var newPin = Substitute.For <Func <byte, IPinInterface> >(); newPin.Invoke(Arg.Any <byte>()).Returns(p => new StubPinInterface(p.Arg <byte>())); var board = new BroadcomBoard(newPin); var pins = new StubPinInterface[28]; //act for (var x = 0; x < 28; x++) { pins[x] = (StubPinInterface)board.GetType().GetProperty($"GPIO{x}").GetValue(board); } //assert for (var x = 0; x < 28; x++) { Assert.Equal(x, pins[x].Pin); } }