예제 #1
0
        public void Should_initialize_instance(decimal value)
        {
            var actual = new INR(value);

            Assert.IsAssignableFrom <INR>(actual);
            Assert.AreEqual(value, actual.Value, nameof(actual.Value));
        }
예제 #2
0
        public void Should_compare_with_null_instance(decimal value)
        {
            var instance = new INR(value);

            Assert.IsFalse(instance.Equals(null), "Equals");
            Assert.AreEqual(1, instance.CompareTo(null), "CompareTo");
        }
예제 #3
0
        public void Should_throw_exception_on_division_by_zero(decimal value)
        {
            var instance = new INR(value);

            Assert.Throws <DivideByZeroException>(() => {
                var unused = instance / 0;
            });
        }
예제 #4
0
        public void Should_cast_to_decimal(decimal value)
        {
            var instance = new INR(value);

            var actual = (decimal)instance;

            Assert.AreEqual(value, actual);
        }
예제 #5
0
        public void Should_cast_from_decimal(decimal value)
        {
            var expected = new INR(value);

            var actual = (INR)value;

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void Should_compare_with_another_type_of_instance(decimal value)
        {
            var    instance1 = new INR(value);
            object instance2 = value;

            Assert.IsFalse(instance1.Equals(instance2), "Equals");
            Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo");
        }
예제 #7
0
        public void Should_round_value_withDigit(double value, double expectedValue)
        {
            var expected = new INR((decimal)expectedValue);

            var instance = new INR((decimal)value);
            var actual   = instance.Round(1);

            Assert.AreEqual(expected, actual);
        }
예제 #8
0
        public void Should_roundvalue_withMode(MidpointRounding mode, double value, double expectedValue)
        {
            var expected = new INR((decimal)expectedValue);

            var instance = new INR((decimal)value);
            var actual   = instance.Round(mode);

            Assert.AreEqual(expected, actual);
        }
예제 #9
0
        public void Should_format_string(string format, string mask)
        {
            var expected = string.Format(Consts.CultureEnUS, mask, 1.7578m);

            var instance = new INR(1.7578m);
            var actual   = instance.ToString(format, Consts.CultureEnUS);

            Assert.AreEqual(expected, actual);
        }
예제 #10
0
        public void Should_own_a_HashCode(decimal value)
        {
            var expected = value.GetHashCode();

            var instance = new INR(value);
            var actual   = instance.GetHashCode();

            Assert.AreEqual(expected, actual);
        }
예제 #11
0
        public void Should_convert_to_string(decimal value)
        {
            var expected = $"₹ {value:0.00}";

            var instance = new INR(value);
            var actual   = instance.ToString();

            Assert.AreEqual(expected, actual);
        }
예제 #12
0
        public void Should_floor_value(double value, double expectedValue)
        {
            var expected = new INR((decimal)expectedValue);

            var instance = new INR((decimal)value);
            var actual   = instance.Floor();

            Assert.AreEqual(expected, actual);
        }
예제 #13
0
        public void Should_divide_instance_by_decimal(double leftValue, double rightValue, double expectedValue)
        {
            var expected = new INR((decimal)expectedValue);

            var instance = new INR((decimal)leftValue);
            var actual   = instance / (decimal)rightValue;

            Assert.AreEqual(expected, actual);
        }
예제 #14
0
        public void Should_multiply_decimal_by_instance(double leftValue, double rightValue, double expectedValue)
        {
            var expected = new INR((decimal)expectedValue);

            var instance = new INR((decimal)rightValue);

            var actual = (decimal)leftValue * instance;

            Assert.AreEqual(expected, actual);
        }
예제 #15
0
        public void Should_subtract_two_instances(double leftValue, double rightValue, double expectedValue)
        {
            var expected = new INR((decimal)expectedValue);

            var leftInstance  = new INR((decimal)leftValue);
            var rightInstance = new INR((decimal)rightValue);
            var actual        = leftInstance - rightInstance;

            Assert.AreEqual(expected, actual);
        }
예제 #16
0
        public void Should_compare_with_same_value(decimal value)
        {
            var baseInstance  = new INR(value);
            var otherInstance = new INR(value);

            Assert.IsTrue(baseInstance.Equals(otherInstance), "Equals");
            Assert.IsTrue(baseInstance.Equals((object)otherInstance), "Equals object");

            Assert.IsTrue(baseInstance == otherInstance, "==");
            Assert.IsFalse(baseInstance != otherInstance, "!=");

            Assert.AreEqual(0, baseInstance.CompareTo(otherInstance), "CompareTo");
            Assert.AreEqual(0, baseInstance.CompareTo((object)otherInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < otherInstance, "<");
            Assert.IsFalse(baseInstance > otherInstance, ">");

            Assert.IsTrue(baseInstance <= otherInstance, "<=");
            Assert.IsTrue(baseInstance >= otherInstance, ">=");
        }
예제 #17
0
        public void Should_compare_with_smaller_value(double baseValue, double smallerValue)
        {
            var baseInstance    = new INR((decimal)baseValue);
            var smallerInstance = new INR((decimal)smallerValue);

            Assert.IsFalse(baseInstance.Equals(smallerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)smallerInstance), "Equals object");

            Assert.IsFalse(baseInstance == smallerInstance, "==");
            Assert.IsTrue(baseInstance != smallerInstance, "!=");

            Assert.AreEqual(+1, baseInstance.CompareTo(smallerInstance), "CompareTo");
            Assert.AreEqual(+1, baseInstance.CompareTo((object)smallerInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < smallerInstance, "<");
            Assert.IsTrue(baseInstance > smallerInstance, ">");

            Assert.IsFalse(baseInstance <= smallerInstance, "<=");
            Assert.IsTrue(baseInstance >= smallerInstance, ">=");
        }
예제 #18
0
        public void Should_compare_with_bigger_value(double baseValue, double biggerValue)
        {
            var baseInstance   = new INR((decimal)baseValue);
            var biggerInstance = new INR((decimal)biggerValue);

            Assert.IsFalse(baseInstance.Equals(biggerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)biggerInstance), "Equals object");

            Assert.IsFalse(baseInstance == biggerInstance, "==");
            Assert.IsTrue(baseInstance != biggerInstance, "!=");

            Assert.AreEqual(-1, baseInstance.CompareTo(biggerInstance), "CompareTo");
            Assert.AreEqual(-1, baseInstance.CompareTo((object)biggerInstance), "CompareTo object");

            Assert.IsTrue(baseInstance < biggerInstance, "<");
            Assert.IsFalse(baseInstance > biggerInstance, ">");

            Assert.IsTrue(baseInstance <= biggerInstance, "<=");
            Assert.IsFalse(baseInstance >= biggerInstance, ">=");
        }
예제 #19
0
        public void Should_have_a_symbol(decimal value)
        {
            ICurrency actual = new INR(value);

            Assert.AreEqual(INR.Symbol, actual.Symbol);
        }