'The L{IBoxReceiver} which is started when L{amp.BinaryBoxProtocol} is
connected to a transport can call C{sendBox} on the L{IBoxSender}
passed to it before C{startReceivingBoxes} returns and have that box
sent.'

def test_sendBoxInStartReceivingBoxes(self):

    class SynchronouslySendingReceiver:
        def startReceivingBoxes(self, sender):
            sender.sendBox(amp.Box({'foo': 'bar'}))
    transport = StringTransport()
    protocol = amp.BinaryBoxProtocol(SynchronouslySendingReceiver())
    protocol.makeConnection(transport)
    self.assertEqual(transport.value(), '\x00\x03foo\x00\x03bar\x00\x00')
