Esempio n. 1
0
        public void TestDimensionComparer()
        {
            var def1 = new DimensionDefinition {
                Key = "test1"
            };
            var def2 = new DimensionDefinition {
                Key = "test1"
            };

            Assert.AreEqual(0, DimensionDefinitionComparer.Comparer.Compare(null, null));
            Assert.AreEqual(1, DimensionDefinitionComparer.Comparer.Compare(def1, null));
            Assert.AreEqual(-1, DimensionDefinitionComparer.Comparer.Compare(null, def2));
            Assert.AreEqual(0, DimensionDefinitionComparer.Comparer.Compare(def1, def2));

            def2.Key = "test0";
            Assert.AreEqual(-1, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
            def2.Key = "test1";

            def1.IsDimensionless = true;
            Assert.AreEqual(-1, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
            def2.IsDimensionless = true;
            Assert.AreEqual(0, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
            def1.Vector = true;
            Assert.AreEqual(-1, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
            def2.Vector = true;
            Assert.AreEqual(0, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
            def2.DerivedString = "temperature";
            def2.UpdateDerived();
            Assert.AreEqual(1, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
            def1.DerivedString = "time*time";
            def1.UpdateDerived();
            Assert.AreEqual(0, DimensionDefinitionComparer.Comparer.Compare(def1, def2));
        }
Esempio n. 2
0
        public void TestDimensionFilter()
        {
            var def = new DimensionDefinition {
                Key = "test"
            };

            Assert.IsTrue(MeasurementCorpus.DimensionFilter(def));
            def.Vector = true;
            Assert.IsFalse(MeasurementCorpus.DimensionFilter(def));
            MeasurementCorpus.Options.AllowVectorDimensions = true;
            Assert.IsTrue(MeasurementCorpus.DimensionFilter(def));
            def.DerivedString = "temperature/time";
            def.UpdateDerived();
            Assert.IsTrue(MeasurementCorpus.DimensionFilter(def));
            MeasurementCorpus.Options.AllowDerivedDimensions = false;
            Assert.IsFalse(MeasurementCorpus.DimensionFilter(def));
            MeasurementCorpus.Options.AllowDerivedDimensions = true;
            Assert.IsTrue(MeasurementCorpus.DimensionFilter(def));
            MeasurementCorpus.Options.IgnoredDimensions.Add(def);
            Assert.IsFalse(MeasurementCorpus.DimensionFilter(def));
        }