public void WriteFlags() { // Arrange int extra = -1; int result = -1; m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>())) .Callback <byte[], int, int>((b, i, c) => { extra = b[4]; result = BigEndianConverter.GetInt32(b, 24); }).Returns(0); m_builder.Reset(); m_builder.WriteOperation(RequestOperation.Set); // Act m_builder.WriteFlags(123456789); // Assert m_builder.WriteTo(m_mockBinaryWriter.Object); Assert.Equal(8, extra); Assert.Equal(123456789, result); }
public void WriteFlags() { // Arrange string result = null; m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>())) .Callback <byte[], int, int>((b, i, c) => result = Encoding.ASCII.GetString(b, i, c - 2)).Returns(0); // Act m_builder.WriteFlags(1234567890); // Assert m_builder.WriteTo(m_mockBinaryWriter.Object); Assert.Equal(" 1234567890", result); }