Пример #1
0
        public void InsertNumber_withIndexes_4and3_returns_ArgumentException()
        {
            //Arrange
            int firstNumber  = 8;
            int secondNumber = 15;
            int i            = 4;
            int j            = 3;

            //Assert
            Assert.ThrowsException <ArgumentException>(() => BitsInsert.InsertNumber(firstNumber, secondNumber, i, j));
        }
Пример #2
0
        public void InsertNumber_withNegativeNumbers_returns_ArgumentException()
        {
            //Arrange
            int firstNumber  = -8;
            int secondNumber = -15;
            int i            = 4;
            int j            = 3;

            //Assert
            Assert.ThrowsException <ArgumentException>(() => BitsInsert.InsertNumber(firstNumber, secondNumber, i, j));
        }
Пример #3
0
        public void NegativeValueStBit_BytePasteTest(int stbit, int endbit)
        {
            // arrange
            int first    = 63;
            int second   = 8;
            int startBit = stbit;
            int endBit   = endbit;

            // act
            // assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => BitsInsert.Exec(first, second, startBit, endBit));
        }
Пример #4
0
        public void ZeroValues_BytePasteTest()
        {
            // arrange
            int first    = 0;
            int second   = 0;
            int startBit = 0;
            int endBit   = 0;
            int expected = 0;

            // act
            int result = BitsInsert.Exec(first, second, startBit, endBit);

            // assert
            Assert.AreEqual(expected, result);
        }
Пример #5
0
        public void bothNegativeValue_BytePasteTest()
        {
            // arrange
            int first    = -63;
            int second   = -8;
            int startBit = 0;
            int endBit   = 3;
            int expected = 56;

            // act
            int result = BitsInsert.Exec(first, second, startBit, endBit);

            // assert
            Assert.AreEqual(expected, result);
        }
Пример #6
0
        public void NormalUse_firstBitNotZero_BytePasteTest()
        {
            // arrange
            int first    = 63;
            int second   = 8;
            int startBit = 2;
            int endBit   = 4;
            int expected = 43;

            // act
            int result = BitsInsert.Exec(first, second, startBit, endBit);

            // assert
            Assert.AreEqual(expected, result);
        }
Пример #7
0
        public void InsertNumber_withNumbers_8and15_withIndexes_0and0_returns_9()
        {
            //Arrange
            int firstNumber  = 8;
            int secondNumber = 15;
            int i            = 0;
            int j            = 0;
            int result;
            int expectedResult = 9;

            //Act
            result = BitsInsert.InsertNumber(firstNumber, secondNumber, i, j);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
Пример #8
0
 public void InsertNumber_with_invalid_data_returns_ArgumentExeption(int firstNumber, int secondNumber, int i, int j)
 {
     Assert.Throws <ArgumentException>(() => BitsInsert.InsertNumber(firstNumber, secondNumber, i, j));
 }
Пример #9
0
 public int InsertNumber_returns_correct_result(int firstNumber, int secondNumber, int i, int j)
 {
     return(BitsInsert.InsertNumber(firstNumber, secondNumber, i, j));
 }