private void TestToggle(string name, string jsonName) { ushort state = 999; Func <ushort> propValue = () => api.GetPropertyValue <ushort>(name); using (new AssertionScope()) { api.SetPropertyValue <SetUshortOutputArrayDelegate>("Set" + name + "F", (index, value) => state = value); api.SetPropertyValue <ushort>(name, 1); propValue().Should().Be(1, "because '{0}' was set to 1", name); TestHttpClient.RequestContents.Should().Be(String.Format(@"{{""output"":3,""{0}"":true}}", jsonName)); api.InvokeMethod(name + "Toggle"); propValue().Should().Be(0, "because '{0}' was toggled from 1 to 0.", name); TestHttpClient.RequestContents.Should().Be(String.Format(@"{{""output"":3,""{0}"":false}}", jsonName)); } }