Exemplo n.º 1
0
        public void KeepSum()
        {
            var input = new List <Tuple <string, decimal> >()
            {
                Tuple.Create("a", 1.5051m),
                Tuple.Create("b", 2.5051m),
                Tuple.Create("c", 1.5051m),
                Tuple.Create("d", 1.4047m),
            };
            var res = MoneyRounder.round(input);

            res.Sum(a => a.Item2).Should().Be(6.92m);
        }
Exemplo n.º 2
0
        public void LeaveUnchanged()
        {
            var input = new List <Tuple <string, decimal> >()
            {
                Tuple.Create("a", 1.99m),
                Tuple.Create("b", 2.99m),
                Tuple.Create("c", 1.00m),
                Tuple.Create("d", 1.02m),
            };
            var res = MoneyRounder.round(input);

            res.Sum(a => a.Item2).Should().Be(7m);
        }
Exemplo n.º 3
0
        public void CorrectResult()
        {
            var input = new List <Tuple <string, decimal> >()
            {
                Tuple.Create("a", 1.5051m),
                Tuple.Create("b", 2.5051m),
                Tuple.Create("c", 1.5051m),
                Tuple.Create("d", 1.4047m),
            };
            var res = MoneyRounder.round(input);

            res.ElementAt(0).Item2.Should().Be(1.51m);
            res.ElementAt(1).Item2.Should().Be(2.51m);
            res.ElementAt(2).Item2.Should().Be(1.50m);
            res.ElementAt(3).Item2.Should().Be(1.40m);
        }
Exemplo n.º 4
0
        public void KeepOrder()
        {
            var input = new List <Tuple <string, decimal> >()
            {
                Tuple.Create("a", 1.5051m),
                Tuple.Create("b", 2.5051m),
                Tuple.Create("c", 1.5051m),
                Tuple.Create("d", 1.4047m),
            };
            var res = MoneyRounder.round(input);

            res.ElementAt(0).Item1.ShouldBeEquivalentTo("a");
            res.ElementAt(1).Item1.ShouldBeEquivalentTo("b");
            res.ElementAt(2).Item1.ShouldBeEquivalentTo("c");
            res.ElementAt(3).Item1.ShouldBeEquivalentTo("d");
        }