示例#1
0
        public async Task SetupTest <T>(string aDeviceName, bool aShouldInitialize = true)
            where T : IButtplugDeviceProtocol
        {
            var logMgr = new ButtplugLogManager();

            _testImpl   = new TestDeviceImpl(logMgr, aDeviceName);
            _testDevice = new ButtplugDevice(logMgr, typeof(T), _testImpl);

            if (!aShouldInitialize)
            {
                return;
            }

            await Initialize();
        }
        public async Task TestBaseDevice()
        {
            var logMgr  = new ButtplugLogManager();
            var devImpl = new TestDeviceImpl(logMgr, "Device");
            var dev     = new ButtplugDevice(logMgr, new TestProtocol(logMgr, devImpl), devImpl)
            {
                Index = 2,
            };

            await dev.InitializeAsync(default(CancellationToken));

            (await dev.ParseMessageAsync(new StopDeviceCmd(2), default(CancellationToken))).Should().BeOfType <Ok>();

            dev.Awaiting(async aDevice => await dev.ParseMessageAsync(new RotateCmd(2, new List <RotateCmd.RotateSubcommand>()), default(CancellationToken))).Should().Throw <ButtplugDeviceException>();

            dev.Disconnect();
            dev.Awaiting(async aDevice => await aDevice.ParseMessageAsync(new StopDeviceCmd(2), default(CancellationToken))).Should().Throw <ButtplugDeviceException>();
        }