public void Start_should_throw_on_null_params() { var server = new ConsoleStreamServer(new NullLogger()); Action action = () => server.Start(null, s => { }, new FakeRegistry()); action.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("readLineFunc"); action = () => server.Start(() => "", null, new FakeRegistry()); action.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("writeLineAction"); action = () => server.Start(() => "", s => { }, null); action.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("registry"); }
public void Start_should_accept_echo_request() { var client = new FakeClient(new EchoCommand("Hello!")); var server = new ConsoleStreamServer(new NullLogger()); server.Start(client.SendCommand, client.ReceiveResponse, new FakeRegistry()); client.Responses.First().Should() .Be("{\"CommandName\":\"Echo\",\"CommandResult\":\"Hello!\",\"ErrorCode\":\"Success\"}"); }
public void Start_should_accept_a_shutdown_request() { var client = new FakeClient(); var server = new ConsoleStreamServer(new NullLogger()); server.Start(client.SendCommand, client.ReceiveResponse, new FakeRegistry()); client.LastResponse.Should() .Be("{\"CommandName\":\"ShutdownServer\",\"CommandResult\":true,\"ErrorCode\":\"Success\"}"); }
public void Start_should_accept_a_registry_read_request() { var client = new FakeClient( new RegistryReadIntValueCommand(RegistryBaseKey.CurrentUser, "SubKey", "IntValue", -1)); var server = new ConsoleStreamServer(new NullLogger()); server.Start(client.SendCommand, client.ReceiveResponse, new FakeRegistry(@"HKCU\SubKey\IntValue=123")); client.Responses.First().Should() .Be("{\"CommandName\":\"RegistryReadIntValue\",\"CommandResult\":123,\"ErrorCode\":\"Success\"}"); }