示例#1
0
        public void Piano_FindKey_WhenKeyDoesNotExist_ShouldReturnNull()
        {
            // Arrange
            Piano p = new Piano();

            // Act
            PianoKey pk = p.FindKey(4, "Q", false);

            // Assert
            Assert.IsNull(pk);
        }
示例#2
0
        public void Piano_FindKey_WhenKeyExists_ShouldReturnKey()
        {
            // Arrange
            Piano p = new Piano();

            // Act
            PianoKey pk = p.FindKey(4, "C", false);

            // Assert
            Assert.AreEqual("C", pk.Name);
            Assert.AreEqual(4, pk.Octave);
            Assert.AreEqual(false, pk.Black);
        }
示例#3
0
        public void Piano_Enable_WhenKeyDoesNotExist_ShouldDoNothing()
        {
            // Arrange
            Piano  p       = new Piano();
            int    oct     = Piano.BASE_OCTAAF + Piano.OCTAVEN;
            string letter  = "C";
            bool   special = false;

            // Act
            p.Enable(oct, letter, special);

            // Assert
            Assert.IsNull(p.FindKey(oct, letter, special));
        }
示例#4
0
        public void Piano_Enable_WhenKeyExists_ShouldSetEnabledToTrue()
        {
            // Arrange
            Piano  p       = new Piano();
            int    oct     = Piano.BASE_OCTAAF;
            string letter  = "C";
            bool   special = false;

            // Act
            p.Enable(oct, letter, special);

            // Assert
            PianoKey pk = p.FindKey(oct, letter, special);

            Assert.IsNotNull(pk);
            Assert.IsTrue(pk.Enabled);
        }
示例#5
0
        public void Piano_ResetAll()
        {
            // Arrange
            Piano  p       = new Piano();
            int    oct     = Piano.BASE_OCTAAF;
            string letter  = "C";
            bool   special = false;

            // Act
            p.Enable(oct, letter, special);
            p.ResetAll();

            // Asset
            PianoKey pk = p.FindKey(oct, letter, special);

            Assert.IsNotNull(pk);
            Assert.IsFalse(pk.Enabled);
        }