public void Assert_try_create_mapper_handles_decimal_correctly()
        {
            var fake = new FakeQueryType {
                Decimal = 12.3m
            };

            var componentData = new ComponentData();

            var query        = new SqlQuery(fake.GetType(), new SqlServerQueryAttribute(null, "Fake"), null, "");
            var queryContext = new QueryContext(query)
            {
                ComponentData = componentData,
            };

            var mapper = MetricMapper.TryCreate(fake.GetType().GetProperty("Decimal"));

            Assert.That(mapper, Is.Not.Null, "Mapping Decimal failed");

            mapper.AddMetric(queryContext, fake);

            const string metricKey = "Fake/Decimal";

            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");

            var condition = componentData.Metrics[metricKey];

            Assert.That(condition, Is.EqualTo(fake.Decimal), "Metric not mapped correctly");
        }
        public void Assert_decimal_is_mapped()
        {
            var fake = new FakeQueryType {Decimal = 12.3m,};
            var componentData = CreateComponentDataForFake(fake, "Decimal");

            const string metricKey = "Fake/Decimal";
            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");
            var condition = componentData.Metrics[metricKey];
            Assert.That(condition, Is.EqualTo(fake.Decimal), "Metric not mapped correctly");
        }
        public void Assert_numeric_types_are_mapped(string propertyName, object value)
        {
            var fake = new FakeQueryType();
            var propertyInfo = fake.GetType().GetProperty(propertyName);
            propertyInfo.SetValue(fake, value, null);

            var componentData = CreateComponentDataForFake(fake, propertyName);

            var metricKey = "Fake/" + propertyName;
            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");
            var condition = componentData.Metrics[metricKey];
            Assert.That(condition, Is.EqualTo(value), "Metric not mapped correctly");
        }
        public void Assert_metric_attribute_on_integer_properties_is_mapped_to_decimal_value(string propertyName)
        {
            var fake = new FakeQueryType();
            var propertyInfo = fake.GetType().GetProperty(propertyName);
            propertyInfo.SetValue(fake, (byte) 100, null);

            var componentData = CreateComponentDataForFake(fake, propertyName);

            var metricKey = "Fake/" + propertyName;
            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");

            var condition = componentData.Metrics[metricKey];
            Assert.That(condition, Is.EqualTo(100m), "Metric not mapped to decimal correctly");
        }
        public void Assert_decimal_is_mapped()
        {
            var fake = new FakeQueryType {
                Decimal = 12.3m,
            };
            var componentData = CreateComponentDataForFake(fake, "Decimal");

            const string metricKey = "Fake/Decimal";

            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");
            var condition = componentData.Metrics[metricKey];

            Assert.That(condition, Is.EqualTo(fake.Decimal), "Metric not mapped correctly");
        }
        public void Assert_numeric_types_are_mapped(string propertyName, object value)
        {
            var fake         = new FakeQueryType();
            var propertyInfo = fake.GetType().GetProperty(propertyName);

            propertyInfo.SetValue(fake, value, null);

            var componentData = CreateComponentDataForFake(fake, propertyName);

            var metricKey = "Fake/" + propertyName;

            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");
            var condition = componentData.Metrics[metricKey];

            Assert.That(condition, Is.EqualTo(value), "Metric not mapped correctly");
        }
        public void Assert_metric_attribute_on_integer_properties_is_mapped_to_decimal_value(string propertyName)
        {
            var fake         = new FakeQueryType();
            var propertyInfo = fake.GetType().GetProperty(propertyName);

            propertyInfo.SetValue(fake, (byte)100, null);

            var componentData = CreateComponentDataForFake(fake, propertyName);

            var metricKey = "Fake/" + propertyName;

            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");

            var condition = componentData.Metrics[metricKey];

            Assert.That(condition, Is.EqualTo(100m), "Metric not mapped to decimal correctly");
        }
        public void Assert_try_create_mapper_handles_decimal_correctly()
        {
            var fake = new FakeQueryType {Decimal = 12.3m};

            var componentData = new ComponentData();

            var query = new SqlQuery(fake.GetType(), new SqlServerQueryAttribute(null, "Fake"), null, "");
            var queryContext = new QueryContext(query) {ComponentData = componentData,};

            var mapper = MetricMapper.TryCreate(fake.GetType().GetProperty("Decimal"));
            Assert.That(mapper, Is.Not.Null, "Mapping Decimal failed");

            mapper.AddMetric(queryContext, fake);

            const string metricKey = "Fake/Decimal";
            Assert.That(componentData.Metrics.ContainsKey(metricKey), "Expected metric with correct name to be added");

            var condition = componentData.Metrics[metricKey];
            Assert.That(condition, Is.EqualTo(fake.Decimal), "Metric not mapped correctly");
        }