Inheritance: IDev2NumberFormatter
コード例 #1
0
        public void Format_Given_NegativeNumber_Where_RoundingDecimalPlacesAreNegative_Expected_RoundingToMultiplesOf10ForEveryNegative()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.12345", enRoundingType.Normal, -1, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = -120d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void Format_Given_0_Where_RoundingDecimalPlacesAreNegative_Expected_0()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("0", enRoundingType.Normal, -1, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 0d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
 public void Format_Where_FormatNumberTOIsNull_Expected_ArgumentNullExcpetion()
 {
     Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
     dev2NumberFormatter.Format(null);
 }
コード例 #4
0
        public void Format_Given_PositiveNumber_Where_RoundingTypeIsUpWithNoDecimalPlaces_Expected_RoundedUp()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.92345", enRoundingType.Up, 0, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            const double expectedDouble = 124d;
            string expected = expectedDouble.ToString(CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void Format_Given_NegativeNumberGreaterThanNegative1000_Where_AdjustDecimalPlacesByNegative3_Expected_0()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-1.12345678911235", enRoundingType.None, 0, true, -3);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 0d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void Format_Given_NegativeNumber_Where_RoundingDecimalPlacesArelessThanWhatIsBeingAdjusted_Expected_RoundingHappensThenDecimalsAreAdded()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.12395678911235", enRoundingType.Normal, 3, true, 4);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = -123.124d;
            string expected = expectedDouble.ToString("###.###0");

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
 public void Format_Where_RoundingDecimalPlacesLessThanNegative14_Expected_InvalidOperation()
 {
     FormatNumberTO formatNumberTO = new FormatNumberTO("123.123", enRoundingType.None, -15, false, 0);
     Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
     dev2NumberFormatter.Format(formatNumberTO);
 }
コード例 #8
0
        public void Format_Given_NegativeNumberWithLessThanThan5DecimalPlaces_Where_AdjustDecimalPlacesBy5_Expected_2DecimalPlaces()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.123", enRoundingType.None, 0, true, 5);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = -123.12300d;
            string expected = expectedDouble.ToString("###.###00");

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
        public void Format_Given_PositiveNumberLessThan1000_Where_AdjustDecimalPlacesByNegative3_Expected_0()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("1.12345678911235", enRoundingType.None, 0, true, -3);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            const double expectedDouble = 0d;
            string expected = expectedDouble.ToString(CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
 public void Format_Where_NumberStringWithSpecialChars_Expected_InvalidOperation()
 {
     FormatNumberTO formatNumberTO = new FormatNumberTO("!@$%*&*(^(^))((.{}:?<>", enRoundingType.None, 0, false, 0);
     Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
     dev2NumberFormatter.Format(formatNumberTO);
 }
コード例 #11
0
        public void Format_Given_PositiveNumber_Where_AdjustDecimalPlacesByNegative1_Expected_AnyValuBelow10IsDropped()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.12345678911235", enRoundingType.None, 0, true, -1);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            const double expectedDouble = 12d;
            string expected = expectedDouble.ToString(CultureInfo.InvariantCulture);
            

            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void Format_Given_0_Where_RoundingTypeIsDown_Expected_0()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("0", enRoundingType.Down, 0, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            const double expectedDouble = 0d;
            string expected = expectedDouble.ToString(CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
        public void Format_Given_NegativeNumber_Where_RoundingTypeIsDownWithDecimalPlaces_Expected_RoundedDown()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.12345", enRoundingType.Down, 2, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            const double expectedDouble = -123.12d;
            string expected = expectedDouble.ToString(CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
        public void Format_Given_PositiveNumber_Where_AdjustDecimalPlacesBy0_Expected_DecimalsAreDropped()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.12345678911235", enRoundingType.None, 0, true, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 123d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #15
0
 public void Format_Where_DecimalPlacesToShowGreaterThanNegative14_Expected_InvalidOperation()
 {
     FormatNumberTO formatNumberTO = new FormatNumberTO("123.123", enRoundingType.None, 0, true, -15);
     Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
     dev2NumberFormatter.Format(formatNumberTO);
 }
コード例 #16
0
        public void Format_Given_NegativeNumberNumberWithMoreThan2DecimalPlaces_Where_AdjustDecimalPlacesBy2_Expected_2DecimalPlaces()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.12345678911235", enRoundingType.None, 0, true, 2);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = -123.12d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #17
0
        public void Format_Given_NegativeNumber_Where_RoundingTypeIsNoneAndAdjustDecimalsIsFalse_Expected_RawNumberBack()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.123456", enRoundingType.None, 0, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);

            Assert.AreEqual(formatNumberTO.Number, actual);
        }
コード例 #18
0
        public void Format_Given_NegativeNumber_Where_AdjustDecimalPlacesByNegative1_Expected_AnyValuAboveNagative10IsDropped()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.12345678911235", enRoundingType.None, 0, true, -1);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = -12d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #19
0
        public void Format_Given_NegativeNumberWithDecimalsThatShouldRoundUp_Where_RoundingTypeIsNormalWithNoDecimalPlaces_Expected_RoundedUp()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.92345", enRoundingType.Normal, 0, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 124;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #20
0
        public void Format_Given_PositiveNumber_Where_RoundingDecimalPlacesAreMoreThanWhatIsBeingAdjusted_Expected_RoundingHappensThenDecimalsAreDropped()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.12395678911235", enRoundingType.Normal, 4, true, 3);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 123.124d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #21
0
        public void Format_Given_PositiveNumber_Where_RoundingTypeIsUpWithDecimalPlaces_Expected_RoundedUp()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.12345", enRoundingType.Up, 2, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 123.13d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #22
0
        public void Format_Given_0_Where_RoundingDecimalPlacesAreLessThanWhatIsBeingAdjusted_Expected_0()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("0", enRoundingType.Normal, 3, true, 4);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = 0d;
            string expected = expectedDouble.ToString("0.0000");

            Assert.AreEqual(expected, actual);
        }
コード例 #23
0
        public void Format_Given_NegativeNumber_Where_RoundingTypeIsDownWithNoDecimalPlaces_Expected_RoundedDown()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("-123.92345", enRoundingType.Down, 0, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            double expectedDouble = -123d;
            string expected = expectedDouble.ToString();

            Assert.AreEqual(expected, actual);
        }
コード例 #24
0
 public void Format_Where_NumberStringIsntANumber_Expected_InvalidOperation()
 {
     FormatNumberTO formatNumberTO = new FormatNumberTO("ABC", enRoundingType.None, 0, false, 0);
     Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
     dev2NumberFormatter.Format(formatNumberTO);
 }
コード例 #25
0
        public void Format_Given_PositiveNumberWithDecimalsThatShouldRoundUp_Where_RoundingTypeIsNormalWithDecimalPlaces_Expected_RoundedUp()
        {
            FormatNumberTO formatNumberTO = new FormatNumberTO("123.12645", enRoundingType.Normal, 2, false, 0);
            Dev2NumberFormatter dev2NumberFormatter = new Dev2NumberFormatter();
            string actual = dev2NumberFormatter.Format(formatNumberTO);
            const double expectedDouble = 123.13d;
            string expected = expectedDouble.ToString(CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual);
        }