Exemplo n.º 1
0
        public void ShouldHaveDifferentHashCodesOnDifferentInstances()
        {
            var a = CustomMouseEffect.Create();
            var b = CustomMouseEffect.Create();

            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
Exemplo n.º 2
0
        public void ShouldSetCorrectColorWithLedIndexer()
        {
            var effect = CustomMouseEffect.Create();

            effect[GridLed.Logo] = Color.Red;

            Assert.AreEqual(Color.Red, effect[GridLed.Logo]);
        }
Exemplo n.º 3
0
        public void ShouldSetCorrectColorWithIndexIndexer()
        {
            var effect = CustomMouseEffect.Create();

            effect[5] = Color.Red;

            Assert.AreEqual(Color.Red, effect[5]);
        }
Exemplo n.º 4
0
        public void ShouldConstructProperMultiArray()
        {
            var effect = CustomMouseEffect.Create();

            effect[2, 2] = Color.Red;
            var array = effect.ToMultiArray();

            Assert.AreEqual(Color.Red, array[2, 2]);
        }
Exemplo n.º 5
0
        public void ShouldNotEqualArbitraryObject()
        {
            var effect = CustomMouseEffect.Create();
            var obj    = new object();

            Assert.False(effect == obj);
            Assert.True(effect != obj);
            Assert.False(effect.Equals(obj));
            Assert.AreNotEqual(effect, obj);
        }
Exemplo n.º 6
0
        public void ShouldNotEqual1DArrayWithInvalidSize()
        {
            var grid = CustomMouseEffect.Create();
            var arr  = new Color[2];

            Assert.False(grid == arr);
            Assert.True(grid != arr);
            Assert.False(grid.Equals(arr));
            Assert.AreNotEqual(grid, arr);
        }
Exemplo n.º 7
0
        public void ShouldNotEqual2DArrayWithInvalidRowCount()
        {
            var effect = CustomMouseEffect.Create();

            var array = new Color[1][];

            Assert.False(effect == array);
            Assert.True(effect != array);
            Assert.False(effect.Equals(array));
            Assert.AreNotEqual(effect, array);
        }
Exemplo n.º 8
0
        public void ShouldCreateWithAllBlackColors()
        {
            var effect = CustomMouseEffect.Create();

            for (var row = 0; row < MouseConstants.MaxRows; row++)
            {
                for (var column = 0; column < MouseConstants.MaxColumns; column++)
                {
                    Assert.AreEqual(Color.Black, effect[row, column]);
                }
            }
        }
Exemplo n.º 9
0
        public void ShouldNotEqual2DArrayWithInvalidColumnCount()
        {
            var effect = CustomMouseEffect.Create();

            var array = new Color[MouseConstants.MaxRows][];

            array[0] = new Color[1];

            Assert.False(effect == array);
            Assert.True(effect != array);
            Assert.False(effect.Equals(array));
            Assert.AreNotEqual(effect, array);
        }
Exemplo n.º 10
0
        public void ShouldSetCorrectColorWithSet()
        {
            var effect = CustomMouseEffect.Create();

            effect.Set(Color.Red);

            for (var row = 0; row < MouseConstants.MaxRows; row++)
            {
                for (var column = 0; column < MouseConstants.MaxColumns; column++)
                {
                    Assert.AreEqual(Color.Red, effect[row, column]);
                }
            }
        }
Exemplo n.º 11
0
        public async Task ApplyAsync(IVirtualLedGrid virtualGrid, CancellationToken cancellationToken = default)
        {
            var keyboardGrid   = CustomKeyboardEffect.Create();
            var mouseGrid      = CustomMouseEffect.Create();
            var mousepadGrid   = CustomMousepadEffect.Create();
            var headsetGrid    = CustomHeadsetEffect.Create();
            var chromaLinkGrid = CustomChromaLinkEffect.Create();

            foreach (var k in virtualGrid)
            {
                switch (k.Type)
                {
                case KeyType.Invalid:
                    break;

                case KeyType.Keyboard:
                    var kbVal = (Key)Enum.Parse(typeof(Key), k.FriendlyName);
                    keyboardGrid[kbVal] = ToColoreColor(k.Color);
                    break;

                case KeyType.Mouse:
                    var mouseVal = (GridLed)Enum.Parse(typeof(GridLed), k.FriendlyName);
                    mouseGrid[mouseVal] = ToColoreColor(k.Color);
                    break;

                case KeyType.Mousepad:
                    mousepadGrid[k.KeyCode] = ToColoreColor(k.Color);
                    break;

                case KeyType.Headset:
                    headsetGrid[k.KeyCode] = ToColoreColor(k.Color);
                    break;

                case KeyType.ChromaLink:
                    chromaLinkGrid[k.KeyCode] = ToColoreColor(k.Color);
                    break;
                }
            }

            await this._chromaInterface.Keyboard.SetCustomAsync(keyboardGrid);

            await this._chromaInterface.Mouse.SetGridAsync(mouseGrid);

            await this._chromaInterface.Mousepad.SetCustomAsync(mousepadGrid);

            await this._chromaInterface.Headset.SetCustomAsync(headsetGrid);

            await this._chromaInterface.ChromaLink.SetCustomAsync(chromaLinkGrid);
        }
Exemplo n.º 12
0
        public override Task ApplyAsync(IVirtualLedGrid virtualGrid, CancellationToken cancellationToken = default)
        {
            if (!this.Initialized)
            {
                return(Task.CompletedTask);
            }

            var mouseGrid = CustomMouseEffect.Create();

            for (var row = 0; row < virtualGrid.RowCount; row++)
            {
                for (var col = 0; col < virtualGrid.ColumnCount; col++)
                {
                    mouseGrid[row, col] = ToColoreColor(virtualGrid[col, row]);
                }
            }

            return(this.ChromaInterface !.Mouse.SetGridAsync(mouseGrid));
        }
Exemplo n.º 13
0
        public void ShouldThrowWhenOutOfRange1DSet()
        {
            var grid = CustomMouseEffect.Create();

            Assert.That(
                () => grid[-1] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => grid[MouseConstants.MaxLeds] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(MouseConstants.MaxLeds));
        }
Exemplo n.º 14
0
        public void ShouldThrowWhenOutOfRange2DGet()
        {
            var effect = CustomMouseEffect.Create();

            // ReSharper disable once NotAccessedVariable
            Color dummy;

            Assert.That(
                () => dummy = effect[-1, 0],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("row")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => dummy = effect[MouseConstants.MaxRows, 0],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("row")
                .And.Property("ActualValue")
                .EqualTo(MouseConstants.MaxRows));

            Assert.That(
                () => dummy = effect[0, -1],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("column")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => dummy = effect[0, MouseConstants.MaxColumns],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("column")
                .And.Property("ActualValue")
                .EqualTo(MouseConstants.MaxColumns));
        }
Exemplo n.º 15
0
        public void ShouldThrowWhenOutOfRange1DGet()
        {
            var grid = CustomMouseEffect.Create();

            // ReSharper disable once NotAccessedVariable
            Color dummy;

            Assert.That(
                () => dummy = grid[-1],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => dummy = grid[MouseConstants.MaxLeds],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(MouseConstants.MaxLeds));
        }
Exemplo n.º 16
0
        public void ShouldThrowWhenOutOfRange2DSet()
        {
            var effect = CustomMouseEffect.Create();

            Assert.That(
                () => effect[-1, 0] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("row")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => effect[MouseConstants.MaxRows, 0] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("row")
                .And.Property("ActualValue")
                .EqualTo(MouseConstants.MaxRows));

            Assert.That(
                () => effect[0, -1] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("column")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => effect[0, MouseConstants.MaxColumns] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("column")
                .And.Property("ActualValue")
                .EqualTo(MouseConstants.MaxColumns));
        }
Exemplo n.º 17
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseImplementation" /> class.
 /// </summary>
 public MouseImplementation(IChromaApi api)
     : base(api)
 {
     Log.Info("Mouse is initializing");
     _custom = CustomMouseEffect.Create();
 }