Exemple #1
0
        public void ShouldSetWithIndexIndexer()
        {
            var grid = DeathstalkerGridEffect.Create();

            grid[2] = Color.Red;

            Assert.AreEqual(Color.Red, grid[2]);
        }
Exemple #2
0
        public void ShouldClearToBlack()
        {
            var grid = new DeathstalkerGridEffect(Color.Pink);

            grid.Clear();

            Assert.That(grid, Is.EqualTo(DeathstalkerGridEffect.Create()));
        }
Exemple #3
0
        public void ShouldNotEqualNull()
        {
            var grid = DeathstalkerGridEffect.Create();

            Assert.False(grid == null);
            Assert.True(grid != null);
            Assert.AreNotEqual(grid, null);
        }
Exemple #4
0
        public void ShouldSetNewColors()
        {
            var grid = DeathstalkerGridEffect.Create();

            grid[1] = Color.Red;

            Assert.That(grid[1], Is.EqualTo(Color.Red));
        }
Exemple #5
0
        public void ClonedStructShouldBeIndependent()
        {
            var original = new DeathstalkerGridEffect(Color.Red);
            var clone    = original.Clone();

            clone.Set(Color.Blue);

            Assert.That(clone, Is.Not.EqualTo(original));
        }
Exemple #6
0
        public void ShouldSetAllColorsWithColorCtor()
        {
            var grid = new DeathstalkerGridEffect(Color.Red);

            for (var index = 0; index < KeyboardConstants.MaxDeathstalkerZones; index++)
            {
                Assert.That(grid[index], Is.EqualTo(Color.Red));
            }
        }
Exemple #7
0
        public void ShouldSetToBlackWithCreate()
        {
            var grid = DeathstalkerGridEffect.Create();

            for (var index = 0; index < KeyboardConstants.MaxDeathstalkerZones; index++)
            {
                Assert.That(grid[index], Is.EqualTo(Color.Black));
            }
        }
Exemple #8
0
        public void ShouldNotEqualArbitraryObject()
        {
            var grid = DeathstalkerGridEffect.Create();
            var obj  = new object();

            Assert.False(grid == obj);
            Assert.True(grid != obj);
            Assert.False(grid.Equals(obj));
            Assert.AreNotEqual(grid, obj);
        }
Exemple #9
0
        public void ShouldNotEqualDifferentGrid()
        {
            var a = new DeathstalkerGridEffect(Color.Red);
            var b = new DeathstalkerGridEffect(Color.Pink);

            Assert.False(a == b);
            Assert.True(a != b);
            Assert.False(a.Equals(b));
            Assert.AreNotEqual(a, b);
        }
Exemple #10
0
        public void ShouldEqualIdenticalGrid()
        {
            var a = new DeathstalkerGridEffect(Color.Red);
            var b = new DeathstalkerGridEffect(Color.Red);

            Assert.True(a == b);
            Assert.False(a != b);
            Assert.True(a.Equals(b));
            Assert.AreEqual(a, b);
        }
Exemple #11
0
        public void ClonedStructShouldBeIdentical()
        {
            var original = new DeathstalkerGridEffect(Color.Red)
            {
                [1] = Color.Green,
                [3] = Color.Orange,
                [4] = Color.Orange
            };
            var clone = original.Clone();

            Assert.That(clone, Is.EqualTo(original));
        }
Exemple #12
0
        public void ShouldConstructProperMultiArray()
        {
            var effect = DeathstalkerGridEffect.Create();

            effect[0] = Color.Red;
            effect[1] = Color.Green;
            effect[5] = Color.Blue;
            var multiArray = effect.ToMultiArray();

            Assert.AreEqual(Color.Red, multiArray[1, 1]);
            Assert.AreEqual(Color.Green, multiArray[1, 4]);
            Assert.AreEqual(Color.Blue, multiArray[1, 18]);
        }
        /// <inheritdoc />
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyboardImplementation" /> class.
        /// </summary>
        public KeyboardImplementation(IChromaApi api)
            : base(api)
        {
            Log.Info("Keyboard initializing...");

            CurrentEffectId = Guid.Empty;

            // We keep a local copy of a grid to speed up grid operations
            Log.Debug("Initializing private copy of Custom");
            _grid = CustomKeyboardEffect.Create();

            Log.Debug("Initializing private copy of Deathstalker grid");
            _deathstalkerGrid = DeathstalkerGridEffect.Create();
        }
Exemple #14
0
        public void ShouldThrowWhenOutOfRange1DSet()
        {
            var grid = DeathstalkerGridEffect.Create();

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

            Assert.That(
                () => grid[KeyboardConstants.MaxDeathstalkerZones] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(KeyboardConstants.MaxDeathstalkerZones));
        }
Exemple #15
0
        public void ShouldThrowWhenOutOfRange1DGet()
        {
            var grid = DeathstalkerGridEffect.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[KeyboardConstants.MaxDeathstalkerZones],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(KeyboardConstants.MaxDeathstalkerZones));
        }
Exemple #16
0
        public void ShouldGetWithIndexIndexer()
        {
            var grid = new DeathstalkerGridEffect(Color.Red);

            Assert.AreEqual(Color.Red, grid[3]);
        }
Exemple #17
0
        public void ShouldHaveZeroHashCodeOnDefaultInstance()
        {
            var effect = new DeathstalkerGridEffect();

            Assert.Zero(effect.GetHashCode());
        }