Exemplo n.º 1
0
    public void Users_CanQueryUnusedDevices()
    {
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();
        var mouse    = InputSystem.AddDevice <Mouse>();
        var touch    = InputSystem.AddDevice <Touchscreen>();
        var gyro     = InputSystem.AddDevice <Gyroscope>();

        var user1 = new TestUser();
        var user2 = new TestUser();
        var user3 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);
        InputUser.Add(user3);

        user1.AssignInputDevice(gamepad);
        user3.AssignInputDevices(new InputDevice[] { keyboard, mouse });

        using (var unusedDevices = InputUser.GetUnusedDevices())
        {
            Assert.That(unusedDevices, Has.Count.EqualTo(2));
            Assert.That(unusedDevices, Has.Exactly(1).SameAs(touch));
            Assert.That(unusedDevices, Has.Exactly(1).SameAs(gyro));
        }
    }