Ejemplo n.º 1
0
        public void CanHandleResends()
        {
            var printer   = CreateTestProbe();
            var protocol  = ActorOf(PrinterProtocol.Props(printer));
            var transport = CreateTestProbe();

            protocol.Tell(new ConnectProtocol(transport), TestActor);
            transport.ExpectMsg <ConnectTransport>();

            // Simulate transport connection behavior.
            // Otherwise the protocol layer will get stuck.
            protocol.Tell(TransportConnected.Instance, transport.Ref);

            protocol.Tell(new PrinterCommand(1, "G0"), TestActor);
            transport.ExpectMsg <PrinterCommand>(x => x.LineNumber == 1);

            protocol.Tell(new PrinterResponse("ok"), transport);

            protocol.Tell(new PrinterCommand(2, "G1"), TestActor);
            transport.ExpectMsg <PrinterCommand>(x => x.LineNumber == 2);

            protocol.Tell(new PrinterResponse("rsnd N:1"), transport);
            transport.ExpectMsg <PrinterCommand>(x => x.LineNumber == 1);

            protocol.Tell(new PrinterResponse("ok"), transport);
            transport.ExpectMsg <PrinterCommand>(x => x.LineNumber == 2);

            protocol.Tell(new PrinterResponse("ok"), transport);
        }
Ejemplo n.º 2
0
        public void CanHandleAsyncTemperatureReports()
        {
            var printer   = CreateTestProbe();
            var protocol  = ActorOf(PrinterProtocol.Props(printer));
            var transport = CreateTestProbe();

            //TODO: Send a command and reply with an out-of-band temperature report + ok.
        }
Ejemplo n.º 3
0
        public void CanConnect()
        {
            var printer   = CreateTestProbe();
            var protocol  = ActorOf(PrinterProtocol.Props(printer));
            var transport = CreateTestProbe();

            protocol.Tell(new ConnectProtocol(transport), TestActor);
            transport.ExpectMsg <ConnectTransport>();

            // Simulate transport connection behavior.
            // Otherwise the protocol layer will get stuck.
            protocol.Tell(TransportConnected.Instance, transport.Ref);

            protocol.Tell(DisconnectProtocol.Instance, TestActor);
            transport.ExpectMsg <DisconnectTransport>();

            // Simulate transport disconnection behavior.
            // Otherwise the protocol layer will get stuck.
            protocol.Tell(TransportDisconnected.Instance, transport.Ref);
        }