Ejemplo n.º 1
0
        public void CollapseTest()
        {
            #region Test unit collapsing
            {
                var metricSystem = new MetricSystem("metricSystemX");
                var quantity     = new BaseQuantity("quantityX");
                try
                {
                    var unit = new BaseUnit(metricSystem, quantity, "unitX", "X");
                    #region For base unit
                    {
                        var collapsedUnit = unit.Collapse();
                        Assert.AreEqual(unit, collapsedUnit, "A collapsed base unit " +
                                        "should be equal to itself.");
                    }
                    #endregion ;

                    var derivedUnit = unit * unit / unit;
                    #region For derived unit
                    {
                        var collapsedDerivedUnit = derivedUnit.Collapse();
                        Assert.AreEqual(unit, collapsedDerivedUnit, "A collapsed derived unit " +
                                        "X*X/X should result in X.");
                    }
                    #endregion
                }
                catch (Exception e)
                {
                    if (e is UnitTestAssertException)
                    {
                        throw e;
                    }

                    Assert.Fail("Collapsing should not fail internally.", e);
                }
            }
            #endregion
        }