コード例 #1
0
        public void Setup()
        {
            _config         = new CConfig();
            _devices        = new List <CDevice>();
            _lights         = new List <CLight>();
            _clientsHandler = new CClientsHandler(_lights);
            _serverThread   = new Thread(new ThreadStart(ServerThreadProc));
            _stopEvent      = new ManualResetEvent(false);

            _socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
            _socket.ReceiveTimeout = 5000;

            Startup("boblight.conf");
        }
コード例 #2
0
        public void Device_Should_WriteCorrectData_WhenNoClientsAreConnected()
        {
            CClientsHandler clients = new CClientsHandler(lights);

            rs232Device = CreateRS232Device(clients);

            rs232Device.Run(2);

            MockSerialPort mockSerialPort = MockSerialPort.Instance;

            Assert.AreEqual(START_WRITES + 2 + CLOSE_WRITES, mockSerialPort.Writes.Count);

            byte[] expectedBytes = { 0x41, 0x64, 0x61, 0x00, 0x18, 0x4D, 0, 0, 0, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA };

            Assert.AreEqual(expectedBytes, mockSerialPort.Writes[3]);
            Assert.AreEqual(expectedBytes, mockSerialPort.Writes[4]);
        }