public void TestSerializationQuantityWithExplicitFormula()
        {
            Observer x1 = CreateObject <Observer>().WithName("Quentin").WithDimension(DimensionLength);

            x1.ParentContainer = C1;
            x1.IsFixedValue    = false;
            x1.Persistable     = false;
            x1.Formula         = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);

            ExplicitFormula f1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);

            f1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            f1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            f1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));
            f1.ResolveObjectPathsFor(P);
            f1.FormulaString = "Paul + Peter + Pitter";

            P1.Value = 1.0;
            P0.Value = 10.0;
            P2.Value = 2.0;

            x1.Formula = f1;

            IQuantity x2 = SerializeAndDeserialize(x1);

            x2.ParentContainer = C1;
            x2.Formula.ResolveObjectPathsFor(x2);

            AssertForSpecs.AreEqualQuantity(x2, x1);
        }
        public void TestSerializationTableFormulaWithArgument()
        {
            var x1 = CreateObject <TableFormulaWithXArgument>().WithName("Fortunato").WithDimension(DimensionLength);

            x1.AddTableObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            x1.AddXArgumentObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));

            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualTableFormulaWithArgument(x2, x1);
        }
        public void TestSerializationFormulaWithObjectPathsWithoutObjectReferences()
        {
            ExplicitFormula x1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);

            x1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));

            IFormula x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualFormula(x2, x1);
        }
Пример #4
0
        protected override void Context()
        {
            sut = new DistributedParameter();
            var pathFactory = new ObjectPathFactory(new AliasCreator());

            _meanParameter = new Parameter {
                Name = Constants.Distribution.MEAN
            }.WithFormula(new ExplicitFormula("0"));
            _stdParameter = new Parameter {
                Name = Constants.Distribution.DEVIATION
            }.WithFormula(new ExplicitFormula("1"));
            _percentileParameter = new Parameter {
                Name = Constants.Distribution.PERCENTILE
            }.WithFormula(new ExplicitFormula("0.5"));
            sut.Add(_meanParameter);
            sut.Add(_stdParameter);
            sut.Add(_percentileParameter);
            sut.Formula = new NormalDistributionFormula();
            sut.Formula.AddObjectPath(pathFactory.CreateRelativeFormulaUsablePath(sut, _meanParameter));
            sut.Formula.AddObjectPath(pathFactory.CreateRelativeFormulaUsablePath(sut, _stdParameter));
            sut.Formula.ResolveObjectPathsFor(sut);
        }
Пример #5
0
        protected override void Context()
        {
            base.Context();
            var pathFactory = new ObjectPathFactory(new AliasCreator());

            _distributedParameter = new DistributedParameter();
            var meanParameter = new Parameter {
                Name = Constants.Distribution.MEAN
            }.WithFormula(new ExplicitFormula("0"));
            var stdParameter = new Parameter {
                Name = Constants.Distribution.DEVIATION
            }.WithFormula(new ExplicitFormula("1"));
            var percentileParameter = new Parameter {
                Name = Constants.Distribution.PERCENTILE
            }.WithFormula(new ExplicitFormula("0.7"));

            _distributedParameter.Add(meanParameter);
            _distributedParameter.Add(stdParameter);
            _distributedParameter.Add(percentileParameter);
            _distributedParameter.Formula = new NormalDistributionFormula();
            _distributedParameter.Formula.AddObjectPath(pathFactory.CreateRelativeFormulaUsablePath(_distributedParameter, meanParameter));
            _distributedParameter.Formula.AddObjectPath(pathFactory.CreateRelativeFormulaUsablePath(_distributedParameter, stdParameter));
        }
        public void TestSerialization()
        {
            ConstantFormula x1 = CreateObject <ConstantFormula>().WithName("Fortunato").WithDimension(DimensionLength).WithValue(5.3);

            x1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));
            x1.ResolveObjectPathsFor(P);

            ConstantFormula x2 = SerializeAndDeserialize(x1);

            x2.ResolveObjectPathsFor(P);

            AssertForSpecs.AreEqualConstantFormula(x2, x1);
        }
        public void TestSerialization()
        {
            ExplicitFormula x1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);

            x1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));
            x1.ResolveObjectPathsFor(P);
            x1.FormulaString = "1.1 + 2.2";

            ExplicitFormula x2 = SerializeAndDeserialize(x1);

            x2.ResolveObjectPathsFor(P);

            AssertForSpecs.AreEqualExplicitFormula(x2, x1);
        }
        public void TestSerializationWithDependencies()
        {
            ExplicitFormula x1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);

            x1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            x1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));
            x1.ResolveObjectPathsFor(P);
            x1.FormulaString = "Paul + Peter + Pitter";

            P1.Value = 1.0;
            P0.Value = 10.0;
            P2.Value = 2.0;

            ExplicitFormula x2 = SerializeAndDeserialize(x1);

            x2.ResolveObjectPathsFor(P);

            AssertForSpecs.AreEqualExplicitFormula(x2, x1);
        }