Esempio n. 1
0
        public static void CurrentThrowsException()
        {
            // Arragne
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(16);

            // Assert
            _ = Assert.Throws <InvalidOperationException>(() => _ = testObj.Current);
        }
Esempio n. 2
0
        public static void TestCompileInteger(int number, string expected)
        {
            // Arrange
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(number);

            // Assert
            Assert.AreEqual(expected, testObj.ToString());
        }
Esempio n. 3
0
        public static void TestToInt64(int number, int expected)
        {
            // Arrange
            var testObj = new BitArray(6);

            // Act
            testObj.Compile(number);

            // Assert
            Assert.AreEqual(expected, testObj.ToInt64());
        }
Esempio n. 4
0
        public static void TestNumberOfZeroBits(int number, int expected)
        {
            // Arrange
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(number);

            // Assert
            Assert.AreEqual(expected, testObj.NumberOfZeroBits());
        }
Esempio n. 5
0
        public static void TestCompileIntegerThrowsException(int number, int arrayLength)
        {
            // Arrange
            var testObj = new BitArray(arrayLength);

            // Act
            void Act() => testObj.Compile(number);

            // Assert
            Assert.Throws <ArgumentException>(Act);
        }
Esempio n. 6
0
        public static void TestCompileLongThrowsException(int number, int arrLen)
        {
            // Arrange
            var testObj = new BitArray(arrLen);

            // Act
            void Act() => testObj.Compile((long)number);

            // Assert
            Assert.Throws <ArgumentException>(Act);
        }
Esempio n. 7
0
        public static void TestCompileToStringThorwsException(string sequence, int arrLen)
        {
            // Arrange
            var testObj = new BitArray(arrLen);

            // Act
            void Act() => testObj.Compile(sequence);

            // Assert
            Assert.Throws <ArgumentException>(Act);
        }
Esempio n. 8
0
        public static void TestCompileToString(string sequence, string expectedSequence)
        {
            // Arrange
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(sequence);

            // Assert
            Assert.AreEqual(expectedSequence, testObj.ToString());
        }
Esempio n. 9
0
        public static void TestParity()
        {
            // Arrange
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(26);

            // Assert
            Assert.IsFalse(testObj.EvenParity());
            Assert.IsTrue(testObj.OddParity());
        }
Esempio n. 10
0
        public static void TestOperatorShiftRight(int number, string expected)
        {
            // Arrange
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(number);
            testObj >>= 2;

            // Assert
            Assert.AreEqual(expected, testObj.ToString());
        }
Esempio n. 11
0
        public static void TestCompileIntegerThrowsException(int number, string expectedErrorMsg, int arrayLength)
        {
            // Arrange
            var testObj = new BitArray(arrayLength);

            // Act
            void Act() => testObj.Compile(number);

            // Assert
            var ex = Assert.Throws <Exception>(Act);

            Assert.AreEqual(expectedErrorMsg, ex.Message);
        }
Esempio n. 12
0
        public static void TestIndexer()
        {
            // Arrange
            var testObj = new BitArray(5);

            // Act
            testObj.Compile(24);

            // Assert
            Assert.IsTrue(testObj[0]);
            Assert.IsTrue(testObj[1]);
            Assert.IsFalse(testObj[3]);
        }
Esempio n. 13
0
        public static void TestOperatorAndAndDiffSizes(int t1, int s1, int t2, int s2, string expected)
        {
            // Arrange
            var testObj1 = new BitArray(s1);
            var testObj2 = new BitArray(s2);

            // Act
            testObj1.Compile(t1);
            testObj2.Compile(t2);
            var result = testObj1 & testObj2;

            // Assert
            Assert.AreEqual(expected, result.ToString());
        }
Esempio n. 14
0
        public static void TestHasCode()
        {
            // Arrange
            const int num     = 5;
            var       testObj = new BitArray(3);

            // Act
            testObj.Compile(num);
            var result = testObj.GetHashCode();

            // Assert
            Assert.NotNull(result);
            Assert.AreEqual(5, result);
        }
Esempio n. 15
0
        public static void TestOperatorXor(int testNum, int testNum2, int expected)
        {
            // Arrange
            var testObj1 = new BitArray(5);
            var testObj2 = new BitArray(5);

            // Act
            testObj1.Compile(testNum);
            testObj2.Compile(testNum2);

            var result = testObj1 ^ testObj2;

            // Assert
            Assert.AreEqual(expected, result.ToInt32());
        }
Esempio n. 16
0
        public static void TestOperatorOr(int tObj1, int tObj2, string expected)
        {
            // Arrange
            var testObj1 = new BitArray(5);
            var testObj2 = new BitArray(5);

            // Act
            testObj1.Compile(tObj1);
            testObj2.Compile(tObj2);

            var result = testObj1 | testObj2;

            // Assert
            Assert.AreEqual(expected, result.ToString());
        }
Esempio n. 17
0
        public static void TestCompileLongThrowsException(int number, int arrLen)
        {
            // Arrange
            var testObj = new BitArray(arrLen);

            // Act
            void Act() => testObj.Compile((long)number);

            // Assert
            var ex = Assert.Throws <Exception>(Act);

            Assert.AreEqual(number < 0 ?
                            "Compile: only positive numbers > 0" :
                            "Compile: not apt length!", ex.Message);
        }
Esempio n. 18
0
        public static void TestCompileToStringThorwsException(string sequence, int arrLen)
        {
            // Arrange
            var testObj = new BitArray(arrLen);

            // Act
            void Act() => testObj.Compile(sequence);

            // Assert
            var ex = Assert.Throws <Exception>(Act);

            if (sequence.Length > arrLen || sequence.Length < arrLen)
            {
                Assert.AreEqual("Compile: not equal length!", ex.Message);
            }
        }