Exemplo n.º 1
0
 [TestMethod] public void IsLessTest()
 {
     Assert.IsTrue(Decimals.IsLess(decimal.MinValue, decimal.MaxValue));
     Assert.IsTrue(Decimals.IsLess(d1, decimal.MaxValue));
     Assert.IsTrue(Decimals.IsLess(decimal.MinValue, Decimals.Add(decimal.MinValue, 1)));
     Assert.IsTrue(Decimals.IsLess(Decimals.Add(decimal.MinValue, 1), d1));
     Assert.IsFalse(Decimals.IsLess(d1, Decimals.Add(decimal.MinValue, 1)));
     Assert.IsFalse(Decimals.IsLess(d1, d1));
 }
Exemplo n.º 2
0
 [TestMethod] public void IsGreaterTest()
 {
     Assert.IsTrue(Decimals.IsGreater(decimal.MaxValue, decimal.MinValue));
     Assert.IsTrue(Decimals.IsGreater(decimal.MaxValue, d1));
     Assert.IsTrue(Decimals.IsGreater(Decimals.Add(decimal.MinValue, 1), decimal.MinValue));
     Assert.IsTrue(Decimals.IsGreater(Decimals.Add(d1, 1), d1));
     Assert.IsFalse(Decimals.IsGreater(decimal.MinValue, d1));
     Assert.IsFalse(Decimals.IsGreater(d1, d1));
 }
Exemplo n.º 3
0
        [TestMethod] public void AddTest()
        {
            Assert.AreEqual(d1 + d2, Decimals.Add(d1, d2));
            Assert.AreEqual(0, Decimals.Add(-d1, d1));
            Assert.AreEqual(0, Decimals.Add(decimal.MinValue, decimal.MaxValue));
            Assert.AreEqual(decimal.MaxValue, Decimals.Add(decimal.MaxValue, decimal.MaxValue));
            Assert.AreEqual(decimal.MaxValue, Decimals.Add(decimal.MinValue, decimal.MinValue));
            var absRandomDecimal = Math.Abs(d1);

            Assert.AreEqual(decimal.MaxValue, Decimals.Add(decimal.MaxValue, absRandomDecimal));
            Assert.AreEqual(decimal.MaxValue - absRandomDecimal,
                            Decimals.Add(decimal.MaxValue, -absRandomDecimal));
            Assert.AreEqual(decimal.MinValue + absRandomDecimal,
                            Decimals.Add(decimal.MinValue, absRandomDecimal));
            Assert.AreEqual(decimal.MaxValue, Decimals.Add(decimal.MinValue, -absRandomDecimal));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes this instance, registers all Integers and Doubles
        /// </summary>
        protected void Init()
        {
            var t = GetType();

            if (MetricsExtensions.CachedMetricsDefinitions.ContainsKey(t.FullName))
            {
                MetricsExtensions.CachedMetricsDefinitions[t.FullName].SetTo(this);
                return;
            }



            PropertyInfo[] props = t.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            props = props.ToList().OrderBy(x => x.Name).ToArray();

            foreach (var p in props)
            {
                if (p.hasAttribute(imbAttributeName.measure_excludeFromMetrics))
                {
                    IgnoreComputations.Add(p);
                    IgnoreComputationsDict.Add(p.Name, p);
                    continue;
                }

                if (p.GetIndexParameters().Length == 0)
                {
                    if (p.PropertyType == typeof(Int32))
                    {
                        Integers.Add(p);
                        IntegersDict.Add(p.Name, p);
                    }
                    else if (p.PropertyType == typeof(Double))
                    {
                        Doubles.Add(p);
                        DoublesDict.Add(p.Name, p);
                    }
                    else if (p.PropertyType == typeof(Decimal))
                    {
                        Decimals.Add(p);
                        DecimalsDict.Add(p.Name, p);
                    }
                }
            }

            MetricsExtensions.StoreMetricsDefinition(this);
        }