Ejemplo n.º 1
0
        public void Construct_GivenDecimalValue_ToStringReturnsPeriodFormattedString(decimal input, string expected)
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var decorated = new DecimalDecorator(input);
            var result = decorated.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(result, expected);
        }
Ejemplo n.º 2
0
        public void Construct_GivenNullString_ToDecimalReturns0()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            DecimalDecorator dd = null;
            Assert.DoesNotThrow(() => dd = new DecimalDecorator(null));

            //---------------Test Result -----------------------
            Assert.AreEqual(0m, dd.ToDecimal());
        }
Ejemplo n.º 3
0
        public void Construct_GivenDecimalValue_ToDecimalAlwaysReturnsThatValue()
        {
            //---------------Set up test pack-------------------
            var input = RandomValueGen.GetRandomDecimal();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var decorated = new DecimalDecorator(input);
            var result = decorated.ToDecimal();
            //---------------Test Result -----------------------
            Assert.AreEqual(input, result);
        }
Ejemplo n.º 4
0
        public void Construct_GivenDecimalWithFormatting_ToStringHonorsFormatting()
        {
            //---------------Set up test pack-------------------
            var input = 1.234m;
            var format = "0.0";

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var decorator = new DecimalDecorator(input, format);
            var result = decorator.ToString();

            //---------------Test Result -----------------------
            Assert.AreEqual("1.2", result);
        }
Ejemplo n.º 5
0
        public void Construct_GivenStringDecimalWithPeriodFormatting_ToStringReturnsThatValue()
        {
            //---------------Set up test pack-------------------
            var nfi = new NumberFormatInfo()
            {
                CurrencyDecimalSeparator = ".",
                NumberDecimalSeparator = ".",
                PercentDecimalSeparator = ".",
                CurrencyGroupSeparator = "",
                NumberGroupSeparator = "",
                PercentGroupSeparator = ""
            };
            var input = RandomValueGen.GetRandomDecimal().ToString(nfi);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var decorated = new DecimalDecorator(input);
            var result = decorated.ToString();

            //---------------Test Result -----------------------
            Assert.AreEqual(result, input);
        }
Ejemplo n.º 6
0
        public void Construct_GivenStringValueWIthPeriodFormattedDecimal_ToDecimalReturnsDecimalValue(string input, decimal expected)
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var decorated = new DecimalDecorator(input);
            var result = decorated.ToDecimal();

            //---------------Test Result -----------------------
            Assert.AreEqual(expected, result);
        }