Ejemplo n.º 1
0
        public void PowerOn()
        {
            var stream = new TestStream();

            using var device = new CyberCard(stream);

            // immediate power off
            device.PowerOff();
            Assert.Equal("S\r", Encoding.ASCII.GetString(stream.ToWrittenArray()));

            // power off after 60 minutes
            device.PowerOff(new TimeSpan(1, 0, 0));
            Assert.Equal("S\rS60\r", Encoding.ASCII.GetString(stream.ToWrittenArray()));

            // power reset
            device.PowerReset();
            Assert.Equal("S\rS60\rS00R0000\r", Encoding.ASCII.GetString(stream.ToWrittenArray()));

            // power off after 1 minute and power on after 900 minutes
            device.PowerReset(new TimeSpan(0, 1, 0), new TimeSpan(0, 900, 0));
            Assert.Equal("S\rS60\rS00R0000\rS01R0900\r", Encoding.ASCII.GetString(stream.ToWrittenArray()));

            // power on immediatelly
            device.PowerOn();
            Assert.Equal("S\rS60\rS00R0000\rS01R0900\rW\r", Encoding.ASCII.GetString(stream.ToWrittenArray()));

            // cancel power off
            device.CancelPowerOff();
            Assert.Equal("S\rS60\rS00R0000\rS01R0900\rW\rC\r", Encoding.ASCII.GetString(stream.ToWrittenArray()));
        }