Esempio n. 1
0
 public void HashCodeInt(Integer value, int expected)
 {
     using (Immutability.Guard(value))
     {
         Assert.Equal(expected, value.GetHashCode());
     }
 }
        public void Log(Integer value, double baseValue, double expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Log(baseValue);

                Assert.Equal(expected, actual, 8);
            }
        }
Esempio n. 3
0
        public void LessThan(Integer left, Integer right, bool expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual = left < right;

                Assert.Equal(expected, actual);
            }
        }
        public void Pow(Integer value, int power, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Pow(power);

                Assert.Equal(expected, actual);
            }
        }
        public void Sgn(Integer value, int expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Sgn();

                Assert.Equal(expected, actual);
            }
        }
        public void ToByteArray(Integer value, byte[] expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.ToByteArray();

                Assert.Equal(expected, actual);
            }
        }
        public void Lcm(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual = left.Lcm(right);

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 8
0
        public void LessThanOrEqualInt(Integer left, int right, bool expected)
        {
            using (Immutability.Guard(left))
            {
                var actual = left <= right;

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 9
0
        public void String(Integer value, string expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.ToString();

                Assert.Equal(expected, actual);
            }
        }
        public void Abs(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Abs();

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 11
0
        public void GreaterThanOrEqual(Integer left, Integer right, bool expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual = left >= right;

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 12
0
        public void CastToInt64(Integer value, long expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = (long)value;

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 13
0
        public void CastToInt32(Integer value, int expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = (int)value;

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 14
0
        public void NotEqualsInt(Integer left, int right, bool expected)
        {
            using (Immutability.Guard(left))
            {
                var actual = left != right;

                Assert.Equal(expected, actual);
            }
        }
Esempio n. 15
0
        public static void RemainderZero()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                Assert.Throws <DivideByZeroException>(()
                                                      => value % value);
            }
        }
        public void ModPow(Integer value, Integer power, Integer modulus,
                           Integer expected)
        {
            using (Immutability.Guard(value, power, modulus))
            {
                var actual = value.ModPow(power, modulus);

                Assert.Equal(expected, actual);
            }
        }
        public static void PowInvalid()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                Assert.Throws <ArgumentOutOfRangeException>(()
                                                            => value.Pow(-1));
            }
        }
Esempio n. 18
0
        public static void EqualsNullOrInvalid()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                Assert.False(value.Equals(null));
                Assert.False(value.Equals(""));
            }
        }
Esempio n. 19
0
        public void Remainder(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left % right;
                var actualFu = left.Remainder(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 20
0
        public void Divide(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left / right;
                var actualFu = left.Divide(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 21
0
        public void Multiply(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left * right;
                var actualFu = left.Multiply(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 22
0
        public void Square(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = value * value;
                var actualFu = value.Multiply(value);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 23
0
        public void SubtractInt(Integer left, int right, Integer expected)
        {
            using (Immutability.Guard(left))
            {
                var actualOp = left - right;
                var actualFu = left.Subtract(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 24
0
        public void Decrement(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = value; --actualOp;
                var actualFu = value.Decrement();

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 25
0
        public void LeftShift(Integer value, int shift, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = value << shift;
                var actualFu = value.LeftShift(shift);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 26
0
        public void CompareTo(Integer left, Integer right, int expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual    = left.CompareTo(right);
                var actualObj = left.CompareTo((object)right);

                Assert.Equal(expected, actual);
                Assert.Equal(expected, actualObj);
            }
        }
Esempio n. 27
0
        public void Negate(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = -value;
                var actualFu = value.Negate();

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 28
0
        public void OnesComplement(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = ~value;
                var actualFu = value.OnesComplement();

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
Esempio n. 29
0
        public void BitwiseAnd(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left & right;
                var actualFu = left.BitwiseAnd(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
        public static void DivRemInvalid()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                var remainder = default(Integer);
                Assert.Throws <DivideByZeroException>(()
                                                      => value.DivRem(0, out remainder));
            }
        }