Exemplo n.º 1
0
        public void ByAmount()
        {
            var amount = 42.42M;

            foreach (var by in Gen.Random.Numbers.Decimals(0.001M, 1000M).ToEnumerable().Take(100))
            {
                var result = Gen.Change(amount).By(by).Amount();

                Console.WriteLine("{0} ±{1} -> {2}", amount, by, result);
                Assert.InRange(result, amount - by, amount + by);
            }
        }
Exemplo n.º 2
0
        public void ByMonthsIsInRange()
        {
            var date = DateTimeOffset.Now;

            foreach (var by in Gen.Random.Numbers.Integers(min: 1).ToEnumerable().Take(100))
            {
                var result = Gen.Change(date).By(by).Months();

                Console.WriteLine("{0} ±{1} -> {2}", date, by, result);
                Assert.InRange(result, date.AddMonths(by * -1), date.AddMonths(by));
            }
        }
Exemplo n.º 3
0
        public void BePercent()
        {
            var amount = 42.42;

            foreach (var by in Gen.Random.Numbers.Doubles(0.001, 1000.0).ToEnumerable().Take(100))
            {
                var result = Gen.Change(amount).By(by).Percent();

                Console.WriteLine("{0} ±{1}% -> {2}", amount, by, result);
                Assert.InRange(result, amount - (amount * by / 100.0), amount + (amount * by / 100.0));
            }
        }
Exemplo n.º 4
0
        public void ByTimeSpanIsInRange()
        {
            var date = DateTimeOffset.Now;

            foreach (var by in Gen.Random.Numbers.Integers(min: 1).ToEnumerable().Take(100))
            {
                var span   = TimeSpan.FromMinutes(by);
                var result = Gen.Change(date).By(span);

                Console.WriteLine("{0} ±{1} -> {2}", date, span, result);
                Assert.InRange(result, date.AddMinutes(by * -1), date.AddMinutes(by));
            }
        }