Exemplo n.º 1
0
        public void GenerateTest()
        {
            var config = GeneFactory.Load();

            var actual = GeneFactory.Generate(config.Where(c => c.Key == "slow").Single(), true);

            Assert.AreEqual(200, (int)((KeyValuePair <string, object>)actual.Value).Value);

            actual = GeneFactory.Generate(config.Where(c => c.Key == "take").Single(), false);
            decimal parsed;

            Assert.IsTrue(decimal.TryParse(((KeyValuePair <string, object>)actual.Value).Value.ToString(), out parsed));
            Assert.AreEqual(2, GeneFactory.GetPrecision(parsed));
        }
Exemplo n.º 2
0
        public void GenerateTest()
        {
            var config = new[] { new GeneConfiguration {
                                     Key = "slow", ActualInt = 200
                                 }, new GeneConfiguration {
                                     Key        = "take", Precision = 2, MaxDecimal = 0.06m,
                                     MinDecimal = 0.04m, ActualDecimal = 0.05m
                                 } };

            var actual = GeneFactory.Generate(config.Where(c => c.Key == "slow").Single(), true);

            Assert.AreEqual(200, (int)((KeyValuePair <string, object>)actual.Value).Value);

            actual = GeneFactory.Generate(config.Where(c => c.Key == "take").Single(), false);
            decimal parsed;

            Assert.IsTrue(decimal.TryParse(((KeyValuePair <string, object>)actual.Value).Value.ToString(), out parsed));
            Assert.AreEqual(2, GeneFactory.GetPrecision(parsed));
        }
        public void GenerateTest()
        {
            var config = new[] { new GeneConfiguration {
                                     Key = "slow", Actual = 200
                                 }, new GeneConfiguration {
                                     Key = "take", Precision = 2, Max = 0.06,
                                     Min = 0.04, Actual = 0.05
                                 } };

            RandomizationProvider.Current = new BasicRandomization();
            GeneFactory.Initialize(config);

            var actual = GeneFactory.Generate(config[0], true);

            Assert.AreEqual(200, (double)((KeyValuePair <string, object>)actual.Value).Value);

            RandomizationProvider.Current = new BasicRandomization();
            actual = GeneFactory.Generate(config[1], false);

            Assert.IsTrue(double.TryParse(((KeyValuePair <string, object>)actual.Value).Value.ToString(), out var parsed));
            Assert.AreEqual(2, GeneFactory.GetPrecision(parsed));
        }