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); }
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); }
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()); }
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); }
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); }
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); }