コード例 #1
0
        public void Cuando_recive_valores_son_salvados_solo_los_que_tienen_que_ser_salvados()
        {
            Experiment exp    = new Experiment();
            IDriver    driver = new DriverInt()
            {
                ValueStorage = new ValueStorage()
            };

            IntegerVariable integerVariable = new IntegerVariable(0, "var1")
            {
                Driver = driver, MinValue = 0, MaxValue = 16, LogValues = true
            };

            exp.AddVariable(integerVariable); // 5 bits
            IntegerVariable integerVariable1 = new IntegerVariable(1, "var2")
            {
                Driver = driver, MinValue = 0, MaxValue = 1015
            };

            exp.AddVariable(integerVariable1); // 10 bits
            BoolVariable boolVariable = new BoolVariable(2, "var3")
            {
                Driver = driver, LogValues = true
            };

            exp.AddVariable(boolVariable); // 1 bits
            driver.AddVariable(integerVariable);
            driver.AddVariable(integerVariable1);
            driver.AddVariable(boolVariable);
            logger = new VariableLogger(new List <Experiment>()
            {
                exp
            });
            Dictionary <int, double> varValues = new Dictionary <int, double>
            {
                { 0, 23 },
                { 1, 12 },
            };

            logger.ExperimentsLogger.Count.ShouldEqual(1);
            ExperimentLoggerStub stub = new ExperimentLoggerStub(exp);

            logger.ExperimentsLogger.RemoveAt(0);
            logger.ExperimentsLogger.Add(stub);
            logger.ReceiveVariableValues(varValues);
            stub.ValuesReceive[0].ShouldEqual(23);
            stub.ValuesReceive[1].ShouldEqual(12);
        }
コード例 #2
0
        public void then_can_save_variables()
        {
            Experiment exp    = new Experiment();
            IDriver    driver = new DriverInt()
            {
                ValueStorage = new ValueStorage()
            };

            IntegerVariable integerVariable = new IntegerVariable(0, "var1")
            {
                Driver = driver, MinValue = 0, MaxValue = 16, LogValues = true
            };

            exp.AddVariable(integerVariable); // 5 bits
            IntegerVariable integerVariable1 = new IntegerVariable(1, "var2")
            {
                Driver = driver, MinValue = 0, MaxValue = 1015
            };

            exp.AddVariable(integerVariable1); // 10 bits
            BoolVariable boolVariable = new BoolVariable(2, "var3")
            {
                Driver = driver, LogValues = true
            };

            exp.AddVariable(boolVariable); // 1 bits
            driver.AddVariable(integerVariable);
            driver.AddVariable(integerVariable1);
            driver.AddVariable(boolVariable);
            ExperimentLoggerStub     logger    = new ExperimentLoggerStub(exp);
            Dictionary <int, double> varValues = new Dictionary <int, double>
            {
                { 0, 23 },
                { 1, 12 },
            };

            logger.ReceiveNewVariableValues(varValues);
            exp.Start(0);
            Thread.Sleep(50);
            logger.ExperimentSerializer.Serializers.Count.ShouldEqual(2);
            logger.ExperimentSerializer.Serializers.ElementAt(0).Value.ShouldBeInstanceOfType(typeof(IntegerVariableSerializer));
            logger.ExperimentSerializer.Serializers.ElementAt(1).Value.ShouldBeInstanceOfType(typeof(BoolVariableSerializer));
        }