public void ShouldHaveDifferentHashCodesOnDifferentInstances() { var a = CustomMouseEffect.Create(); var b = CustomMouseEffect.Create(); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void ShouldSetCorrectColorWithLedIndexer() { var effect = CustomMouseEffect.Create(); effect[GridLed.Logo] = Color.Red; Assert.AreEqual(Color.Red, effect[GridLed.Logo]); }
public void ShouldSetCorrectColorWithIndexIndexer() { var effect = CustomMouseEffect.Create(); effect[5] = Color.Red; Assert.AreEqual(Color.Red, effect[5]); }
public void ShouldConstructProperMultiArray() { var effect = CustomMouseEffect.Create(); effect[2, 2] = Color.Red; var array = effect.ToMultiArray(); Assert.AreEqual(Color.Red, array[2, 2]); }
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); }
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); }
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); }
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]); } } }
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); }
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]); } } }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }
/// <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(); }