void Initialize()
        {
            var ptA = new Pointf(0.0f, 1.0f);
            var ptB = new Pointf(10.0f, 0.0f);

            _ev = new SigmoidEvaluator(ptA, ptB, -0.5f);
        }
        void Initialize()
        {
            var ptA = new Pointf(0.0f, 1.0f);
            var ptB = new Pointf(10.0f, 0.0f);

            _ev = new PowerEvaluator(ptA, ptB, .5f);
        }
        public TaskState( NBTag tag )
        {
            if( FormatVersion != tag["FormatVersion"].GetInt() ) throw new FormatException( "Incompatible format." );
            Shapes = tag["Shapes"].GetInt();
            Vertices = tag["Vertices"].GetInt();
            ImprovementCounter = tag["ImprovementCounter"].GetInt();
            MutationCounter = tag["MutationCounter"].GetInt();
            TaskStart = DateTime.UtcNow.Subtract( TimeSpan.FromTicks( tag["ElapsedTime"].GetLong() ) );

            ProjectOptions = new ProjectOptions( tag["ProjectOptions"] );

            BestMatch = new DNA( tag["BestMatch"] );
            CurrentMatch = BestMatch;

            Initializer = (IInitializer)ModuleManager.ReadModule( tag["Initializer"] );
            Mutator = (IMutator)ModuleManager.ReadModule( tag["Mutator"] );
            Evaluator = (IEvaluator)ModuleManager.ReadModule( tag["Evaluator"] );

            byte[] imageBytes = tag["ImageData"].GetBytes();
            using( MemoryStream ms = new MemoryStream( imageBytes ) ) {
                OriginalImage = new Bitmap( ms );
            }

            var statsTag = (NBTList)tag["MutationStats"];
            foreach( NBTag stat in statsTag ) {
                MutationType mutationType = (MutationType)Enum.Parse( typeof( MutationType ), stat["Type"].GetString() );
                MutationCounts[mutationType] = stat["Count"].GetInt();
                MutationImprovements[mutationType] = stat["Sum"].GetDouble();
            }
        }
Exemple #4
0
        public EFQueryCache(IQueryCacheContainerMgr cacheContainerMgr, IEvaluator evaluator)
            : base(cacheContainerMgr)
        {
            evaluator.CheckNull(nameof(evaluator));

            _evaluator = evaluator;
        }
        public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            CommandCallList childCommands = commandCall.Children;
            childCommands.SetUp(evaluator, resultRecorder);
            childCommands.Execute(evaluator, resultRecorder);
            childCommands.Verify(evaluator, resultRecorder);

            String expression = commandCall.Expression;
            Object result = evaluator.Evaluate(expression);

            if (result != null && result is Boolean)
            {
                if ((Boolean) result)
                {
                    ProcessTrueResult(commandCall, resultRecorder);
                }
                else
                {
                    ProcessFalseResult(commandCall, resultRecorder);
                }
            }
            else
            {
                throw new InvalidExpressionException("Expression '" + expression + "' did not produce a boolean result (needed for assertTrue).");
            }
        }
 public ConfigurationDetails(IPredicate predicate, ISerializationProvider serializationProvider, ISourceDataProvider sourceDataProvider, IEvaluator evaluator)
 {
     _predicate = predicate;
     _serializationProvider = serializationProvider;
     _sourceDataProvider = sourceDataProvider;
     _evaluator = evaluator;
 }
        public virtual void CalculateMetrics(FeatureSubsetModel <TOutput> model,
                                             ISubsetSelector subsetSelector, Subset subset, Batch batch, bool needMetrics)
        {
            if (!needMetrics || model == null || model.Metrics != null)
            {
                return;
            }

            using (var ch = Host.Start("Calculate metrics"))
            {
                RoleMappedData testData = subsetSelector.GetTestData(subset, batch);
                // Because the training and test datasets are drawn from the same base dataset, the test data role mappings
                // are the same as for the train data.
                IDataScorerTransform scorePipe      = ScoreUtils.GetScorer(model.Predictor, testData, Host, testData.Schema);
                RoleMappedData       scoredTestData = new RoleMappedData(scorePipe,
                                                                         GetColumnRoles(testData.Schema, scorePipe.Schema));
                // REVIEW: Should we somehow allow the user to customize the evaluator?
                // By what mechanism should we allow that?
                IEvaluator evaluator = GetEvaluator(Host);
                // REVIEW: with the new evaluators, metrics of individual models are no longer
                // printed to the Console. Consider adding an option on the combiner to print them.
                // REVIEW: Consider adding an option to the combiner to save a data view
                // containing all the results of the individual models.
                var metricsDict = evaluator.Evaluate(scoredTestData);
                if (!metricsDict.TryGetValue(MetricKinds.OverallMetrics, out IDataView metricsView))
                {
                    throw Host.Except("Evaluator did not produce any overall metrics");
                }
                // REVIEW: We're assuming that the metrics of interest are always doubles here.
                var metrics = EvaluateUtils.GetMetrics(metricsView, getVectorMetrics: false);
                model.Metrics = metrics.ToArray();
            }
        }
        /// <summary>
        /// Initialise a new instance of the GeneticEngine class with the supplied plug-ins and populate the initial generation.
        /// </summary>
        /// <param name="populator">The populator plug-in. Generates the initial population.</param>
        /// <param name="evaluator">The evaluator plug-in. Provides the fitness function.</param>
        /// <param name="geneticOperator">The genetic operator plug-in. Processes one generation to produce the individuals for the next.</param>
        /// <param name="terminator">The terminator plug-in. Provides the termination condition.</param>
        /// <param name="outputter">The outputter plug-in or null for no output. Outputs each generation.</param>
        /// <param name="generationFactory">The generation factory plug-in or null to use the default. Creates the generation container.</param>
        public GeneticEngine(IPopulator populator, IEvaluator evaluator, IGeneticOperator geneticOperator, ITerminator terminator, IOutputter outputter = null, IGenerationFactory generationFactory = null)
        {
            if (populator == null)
            {
                throw new GeneticEngineException("populator must not be null");
            }

            if (evaluator == null)
            {
                throw new GeneticEngineException("pvaluator must not be null");
            }

            if (geneticOperator == null)
            {
                throw new GeneticEngineException("geneticOperator must not be null");
            }

            if (terminator == null)
            {
                throw new GeneticEngineException("terminator must not be null");
            }

            this.populator = populator;
            this.evaluator = evaluator;
            this.geneticOperator = geneticOperator;
            this.terminator = terminator;
            this.outputter = outputter;
            this.generationFactory = generationFactory == null ? new AATreeGenerationFactory() : generationFactory;

            Setup();
        }
 public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator)
 {
     _predicate = predicate;
     _serializationStore = serializationStore;
     _sourceDataStore = sourceDataStore;
     _evaluator = evaluator;
 }
Exemple #10
0
 public ValueStack(IExceptionHandler handler, IExpressionContext expressionContext)
 {
     Values = new CustomDictionary();
     _exceptionHandler = handler;
     _evaluator = expressionContext.CreateEvaluator(this);
     Persistables = new Dictionary<string, IPersistable>();
 }
Exemple #11
0
        public void TestMathModulo()
        {
            var xml = testXml.Of("TestMathModulo");
            IEvaluator <int> func = engine.Create <int>(xml);
            int rest = func.Evaluate(person);

            Assert.AreEqual(8, rest);
        }
Exemple #12
0
 public NSGA2(IReproduction <TChromosome> crossover,
              IEvaluator <TChromosome> evaluator,
              IReinsertion <TChromosome> reinsertion)
 {
     _crossover   = crossover;
     _evaluator   = evaluator;
     _reinsertion = reinsertion;
 }
Exemple #13
0
        public static object DefaultEval(ArrayRef arrayRef, IEvaluator eval)
        {
            Array array = (Array)arrayRef.ArrayExpr.Eval(eval);

            long[] indices = arrayRef.Indices.Select(i =>
                                                     TypeConversions.ToLong(i.Eval(eval))).ToArray();
            return(array.GetValue(indices));
        }
 private JsonEasyRuleEvaluator(IMetricService metricService = null)
 {
     _easyRuleDymeRuleSvc = new EasyRuleDymeRuleConverter();
     _worldAnalyser       = new JsonPathWorldAnalyser();
     _worldReader         = new JsonPathWorldReader();
     _inferenceEngineSvc  = new DymeInferenceEvaluator(_worldReader, _worldAnalyser, metricService);
     _ruleEvaluatorSvc    = new DymeRuleEvaluator(_worldReader);
 }
Exemple #15
0
        public SimplePlayer(IMoveFinder moveFinder, IEvaluator evaluator)
        {
            if (moveFinder == null) { throw new ArgumentNullException(nameof(moveFinder)); }

            MoveFinder = moveFinder;
            Evaluator = evaluator;
            _numMovesTried = 0;
        }
		public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator, ConfigurationDependencyResolver dependencyResolver)
		{
			_predicate = predicate;
			_serializationStore = serializationStore;
			_sourceDataStore = sourceDataStore;
			_evaluator = evaluator;
			_dependencyResolver = dependencyResolver;
		}
Exemple #17
0
    public void Init()
    {
        PaytableBuilder builder = new PickPaytableBuilder();

        pickEvaluator           = new PickEvaluator("Pick Feature");
        paytable                = new Paytable();
        paytable.PickTableGroup = builder.BuildPickTableGroup();
    }
        // Start is called before the first frame update
        void Start()
        {
            InitBoard();
            gameExecutor   = new GameExecutor(board, DisplayBoard);
            boardEvaluator = new ColumnGameEvaluator(5);

            DisplayBoard();
        }
Exemple #19
0
        public void TestDirectCallOfRegex()
        {
            var xml = testXml.Of("TestDirectCallOfRegex");
            IEvaluator <int> func = engine.Create <int>(xml);
            int result            = func.Evaluate(person);

            Assert.AreEqual(3, result);
        }
Exemple #20
0
        public void TestOptimisticLambda()
        {
            var xml = testXml.Of("TestOptimisticLambda");
            IEvaluator <Person> func = engine.Create <Person>(xml);
            Person relative          = func.Evaluate(person);

            Assert.AreEqual("Katya", relative.Name);
        }
Exemple #21
0
        public void TestMathAdd()
        {
            var xml = testXml.Of("TestMathAdd");
            IEvaluator <int> func = engine.Create <int>(xml);
            int count             = func.Evaluate(person);

            Assert.AreEqual(2000, count);
        }
Exemple #22
0
 public AppController(IHostingEnvironment env, IConfigurationRoot config, ILoggerFactory loggerFactory, IAppRepository repository, IEvaluator evaluator)
 {
     _hostingEnv = env;
     _config     = config;
     _repository = repository;
     _evaluator  = evaluator;
     _logger     = loggerFactory.CreateLogger("AppController");
 }
Exemple #23
0
        public void TestLambdaScalarCount()
        {
            var xml = testXml.Of("TestLambdaScalarCount");
            IEvaluator <int> func = engine.Create <int>(xml);
            int count             = func.Evaluate(person);

            Assert.AreEqual(2, count);
        }
 public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator, ConfigurationDependencyResolver dependencyResolver)
 {
     _predicate          = predicate;
     _serializationStore = serializationStore;
     _sourceDataStore    = sourceDataStore;
     _evaluator          = evaluator;
     _dependencyResolver = dependencyResolver;
 }
Exemple #25
0
        public void TestCallOfStaticMethod()
        {
            var xml = testXml.Of("TestCallOfStaticMethod");
            IEvaluator <string> func = engine.Create <string>(xml);
            string result            = func.Evaluate(person);

            Assert.AreEqual("My name is Alexander", result);
        }
Exemple #26
0
 public ForNode(IEvaluator from, string key, string value, INode body, INode empty)
 {
     this.body  = body;
     this.empty = empty;
     this.from  = from;
     this.key   = key;
     this.value = value;
 }
Exemple #27
0
 public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator, ISerializationFormatter formatter)
 {
     _predicate          = predicate;
     _serializationStore = serializationStore;
     _sourceDataStore    = sourceDataStore;
     _evaluator          = evaluator;
     _formatter          = formatter;
 }
Exemple #28
0
        public void TestCallOfInstanceMethod()
        {
            var xml = testXml.Of("TestCallOfInstanceMethod");
            IEvaluator <string> func = engine.Create <string>(xml);
            string relationship      = func.Evaluate(person);

            Assert.AreEqual("Alexander + Katya", relationship);
        }
Exemple #29
0
 public SpfEvaluationProcessor(IEvaluator <SpfRecord> evaluator,
                               ISpfRecordExplainer recordExplainer,
                               ISpfRecordsJobsProcessor spfRecordsJobsProcessor)
 {
     _evaluator               = evaluator;
     _recordExplainer         = recordExplainer;
     _spfRecordsJobsProcessor = spfRecordsJobsProcessor;
 }
Exemple #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Condition"/> class.
 /// </summary>
 /// <param name="label">The label.</param>
 public Condition(string label)
 {
     _label = label;
     _subconditions = new List<LeftHandSideCondition>();
     _conditionType = ConditionType.Positive;
     _fields = new Term[3];
     _evaluator = new Equals();
 }
Exemple #31
0
 public AlphaBetaAlgorithm(IEvaluator <TState> evaluator, IGenerator <TState, TMove> moveGenerator,
                           IApplier <TState, TMove> applier)
 {
     _evaluator     = evaluator;
     _moveGenerator = moveGenerator;
     _moveApplier   = applier;
     _maxDepth      = 3;
 }
Exemple #32
0
 public ParallelMiniMax(IGame game, Color color, IEvaluator evaluator, IMoveSorter moveSorter, int depth)
 {
     this.game       = game;
     this.color      = color;
     this.evaluator  = evaluator;
     this.moveSorter = moveSorter;
     Depth           = depth;
 }
Exemple #33
0
 public ConfigurationDetails(IPredicate predicate, ISerializationProvider serializationProvider, ISourceDataProvider sourceDataProvider, IEvaluator evaluator, ISitecoreSerializationFormatter formatter)
 {
     _predicate             = predicate;
     _serializationProvider = serializationProvider;
     _sourceDataProvider    = sourceDataProvider;
     _evaluator             = evaluator;
     _formatter             = formatter;
 }
Exemple #34
0
 public ForNode(IEvaluator from, string key, string value, INode body, INode empty)
 {
     this.body = body;
     this.empty = empty;
     this.from = from;
     this.key = key;
     this.value = value;
 }
Exemple #35
0
        public void TestBlockAndRegex()
        {
            var xml = testXml.Of("TestBlockAndRegex");
            IEvaluator <int> func = engine.Create <int>(xml);
            int count             = func.Evaluate(person);

            Assert.AreEqual(1, count);
        }
Exemple #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Condition"/> class.
 /// </summary>
 /// <param name="label">The label.</param>
 public Condition(string label)
 {
     _label         = label;
     _subconditions = new List <LeftHandSideCondition>();
     _conditionType = ConditionType.Positive;
     _fields        = new Term[3];
     _evaluator     = new Equals();
 }
Exemple #37
0
 public NSGA2(IReproduction <TChromosome> crossover,
              IReproduction <TChromosome> mutation,
              IEvaluator <TChromosome> evaluator,
              IReinsertion <TChromosome> reinsertion) :
     this(crossover, evaluator, reinsertion)
 {
     _mutation = mutation;
 }
Exemple #38
0
        void calcColumn(DataRow pRow, string pCol)
        {
            IEvaluator eval = evals[Array.IndexOf <string>(columnsCalc, pCol)];

            object[] vals = ToolRow.copyRowToArr(columnsVars, pRow);
            eval.setVarAll(vals);
            ToolCell.set(pRow, pCol, eval.getResult());
        }
 public Trainer(int nb_inputs, int[] nb_neurons_layer, int population_size, IEvaluator evaluator)
 {
     this.population = new List<DNA>();
     for(int i = 0; i < population_size; i++)
     {
         this.population.Add (new DNA(nb_inputs, nb_neurons_layer));
     }
     this.evaluator = evaluator;
 }
Exemple #40
0
 public GenericToggleAction(ILogger <GenericToggleAction> logger, IFlightConnector flightConnector, IImageLogic imageLogic,
                            IEvaluator evaluator, EnumConverter enumConverter)
 {
     this.logger          = logger;
     this.flightConnector = flightConnector;
     this.imageLogic      = imageLogic;
     this.evaluator       = evaluator;
     this.enumConverter   = enumConverter;
 }
Exemple #41
0
        public void Setup()
        {
            IEvaluator evaluator    = Evaluator;
            var        setupMethods = evaluator.GetType().GetMethods()
                                      .Where(m =>
                                             m.GetCustomAttributes(typeof(SetupAttribute), false).Length > 0);

            evaluator.Setup();
        }
Exemple #42
0
 public LtcService(IEventLogger eventLogger, IUserUnloger userUnloger, IOsUsersReader osUsersReader, IEvaluator evaluator)
 {
     InitializeComponent();
     Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
     _notAdminUserLoggedIn = false;
     _eventLogger = eventLogger;
     _userUnloger = userUnloger;
     _osUsersReader = osUsersReader;
     _evaluator = evaluator;
 }
Exemple #43
0
        private static double[] Evaluate(IEvaluator evaluator, Function[] functions)
        {
            List<double> values = new List<double>();
            foreach (Function function in functions)
            {
                values.Add(evaluator.Evaluate(function));
            }

            return values.ToArray();
        }
 private void increaseLevel(IEvaluator evaluator)
 {
     if (evaluator.GetVariable(LEVEL_VARIABLE) == null)
     {
         evaluator.SetVariable(LEVEL_VARIABLE, 1);
     }
     else
     {
         evaluator.SetVariable(LEVEL_VARIABLE, 1 + (int)evaluator.GetVariable(LEVEL_VARIABLE));
     }
 }
Exemple #45
0
        public void SetupFixBuzProtoForTest()
        {
            IEnumerable<int> list = Enumerable.Range(0, 16);
            List<ValueTokenPair<int, string>> pairs = new List<ValueTokenPair<int, string>> {
                new ValueTokenPair<int, string> {Value=3, Token=fiz},
                new ValueTokenPair<int, string> {Value=5, Token=buz}
            };

            caster = new IntToStringCaster();
            evaluator = new DivisorEvaluator();
            listEvaler = new ListEvaluator<int, int, string>(list, pairs, caster, evaluator);
        }
 public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
 {
     try
     {
         m_command.Execute(commandCall, evaluator, resultRecorder);
     }
     catch (Exception e)
     {
         resultRecorder.Record(Result.Exception);
         OnExceptionCaught(commandCall.Element, e, commandCall.Expression);
     }
 }
 public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
 {
     try
     {
         m_command.Verify(commandCall, evaluator, resultRecorder);
     }
     catch (Exception e)
     {
         resultRecorder.Record(Result.Exception);
         AnnounceThrowableCaught(commandCall.Element, e, commandCall.Expression);
     }
 }
 public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
 {
     try
     {
         m_command.Execute(commandCall, evaluator, resultRecorder);
     }
     catch (Exception e)
     {
         resultRecorder.Error(e);
         AnnounceThrowableCaught(commandCall.Element, e, commandCall.Expression);
     }
 }
Exemple #49
0
        public void Process(IUrlParser parser, IEvaluator evaluator)
        {
            if (parser == null) throw new ArgumentNullException("parser");
            if (evaluator == null) throw new ArgumentNullException("evaluator");

            var words = parser.Parse(_url);
            var buzzwords = words.Where(evaluator.IsBuzzword);
            foreach (var buzzword in buzzwords)
            {
                ApplyEvent(new BuzzwordFoundEvent(buzzword));
            }
        }
        public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside a 'run' is not supported");

            var element = commandCall.Element;

            var href = element.GetAttributeValue("href");
            Check.NotNull(href, "The 'href' attribute must be set for an element containing concordion:run");

            var runnerType = commandCall.Expression;
            var expression = element.GetAttributeValue("params", "concordion");

            if (expression != null)
            {
                evaluator.Evaluate(expression);
            }

            try
            {
                IRunner concordionRunner;
                Runners.TryGetValue(runnerType, out concordionRunner);

                // TODO - re-check this.
                Check.NotNull(concordionRunner, "The runner '" + runnerType + "' cannot be found. "
                        + "Choices: (1) Use 'concordion' as your runner (2) Ensure that the 'concordion.runner." + runnerType
                        + "' System property is set to a name of an IRunner implementation "
                        + "(3) Specify an assembly fully qualified class name of an IRunner implementation");

                var result = concordionRunner.Execute(evaluator.Fixture, commandCall.Resource, href).Result;

                if (result == Result.Success)
                {
                    resultRecorder.Success();
                    AnnounceSuccess(element);
                }
                else if (result == Result.Ignored)
                {
                    resultRecorder.Ignore();
                    AnnounceIgnored(element);
                }
                else
                {
                    resultRecorder.Failure(string.Format("test {0} failed", href), commandCall.Element.ToXml());
                    AnnounceFailure(element);
                }
            }
            catch (Exception e)
            {
                resultRecorder.Error(e);
                AnnounceError(e, element, expression);
            }
        }
 public void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
 {
     IExecuteStrategy strategy;
     if (commandCall.Element.IsNamed("table"))
     {
         strategy = new TableExecuteStrategy();
     }
     else
     {
         strategy = new DefaultExecuteStrategy();
     }
     strategy.Execute(commandCall, evaluator, resultRecorder);
 }
        public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            var pattern = new Regex("(#.+?) *: *(.+)");
            var matcher = pattern.Match(commandCall.Expression);
            if (!matcher.Success)
            {
                throw new InvalidOperationException("The expression for a \"verifyRows\" should be of the form: #var : collectionExpr");
            }

            var loopVariableName = matcher.Groups[1].Value;
            var iterableExpression = matcher.Groups[2].Value;

            var obj = evaluator.Evaluate(iterableExpression);

            Check.NotNull(obj, "Expression returned null (should be an IEnumerable).");
            Check.IsTrue(obj is IEnumerable, obj.GetType() + " is not IEnumerable");
            Check.IsTrue(!(obj is IDictionary), obj.GetType() + " does not have a predictable iteration order");

            var iterable = (IEnumerable)obj;

            var tableSupport = new TableSupport(commandCall);
            var detailRows = tableSupport.GetDetailRows();

            AnnounceExpressionEvaluated(commandCall.Element);

            int index = 0;
            foreach (var loopVar in iterable)
            {
                evaluator.SetVariable(loopVariableName, loopVar);
                Row detailRow;
                if (detailRows.Count > index)
                {
                    detailRow = detailRows[index];
                }
                else
                {
                    detailRow = tableSupport.AddDetailRow();
                    AnnounceSurplusRow(detailRow.RowElement);
                }
                tableSupport.CopyCommandCallsTo(detailRow);
                commandCall.Children.Verify(evaluator, resultRecorder);
                index++;
            }

            for (; index < detailRows.Count; index++) {
                Row detailRow = detailRows[index];
                resultRecorder.Record(Result.Failure);
                AnnounceMissingRow(detailRow.RowElement);
            }
        }
        public SerializationLoader(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IEvaluator evaluator, ISerializationLoaderLogger logger, PredicateRootPathResolver predicateRootPathResolver)
        {
            Assert.ArgumentNotNull(targetDataStore, "serializationProvider");
            Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");
            Assert.ArgumentNotNull(predicate, "predicate");
            Assert.ArgumentNotNull(evaluator, "evaluator");
            Assert.ArgumentNotNull(logger, "logger");
            Assert.ArgumentNotNull(predicateRootPathResolver, "predicateRootPathResolver");

            Logger = logger;
            PredicateRootPathResolver = predicateRootPathResolver;
            Evaluator = evaluator;
            Predicate = predicate;
            TargetDataStore = targetDataStore;
            SourceDataStore = sourceDataStore;
        }
 public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
 {
     object savedTextValue = evaluator.GetVariable(TEXT_VARIABLE);
     object savedHrefValue = evaluator.GetVariable(HREF_VARIABLE);
     try
     {
         evaluator.SetVariable(TEXT_VARIABLE, commandCall.Element.Text);
         evaluator.SetVariable(HREF_VARIABLE, getHref(commandCall.Element));
         m_command.Verify(commandCall, evaluator, resultRecorder);
     }
     finally
     {
         evaluator.SetVariable(TEXT_VARIABLE, savedTextValue);
         evaluator.SetVariable(HREF_VARIABLE, savedHrefValue);
     }
 }
 protected override double ComputeValue(IEvaluator evaluator)
 {
     double x = f.Value(evaluator);
     if (x < 0.0)
     {
         return -1.0;
     }
     else if (x > 0.0)
     {
         return 1.0;
     }
     else
     {
         // Not defined at zero.
         return double.NaN;
     }
 }
        public SerializationLoader(ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore, IPredicate predicate, IEvaluator evaluator, ISerializationLoaderLogger logger, ISyncConfiguration syncConfiguration, PredicateRootPathResolver predicateRootPathResolver)
        {
            Assert.ArgumentNotNull(targetDataStore, nameof(targetDataStore));
            Assert.ArgumentNotNull(sourceDataStore, nameof(sourceDataStore));
            Assert.ArgumentNotNull(predicate, nameof(predicate));
            Assert.ArgumentNotNull(evaluator, nameof(evaluator));
            Assert.ArgumentNotNull(logger, nameof(logger));
            Assert.ArgumentNotNull(predicateRootPathResolver, nameof(predicateRootPathResolver));
            Assert.ArgumentNotNull(syncConfiguration, nameof(syncConfiguration));

            Logger = logger;
            SyncConfiguration = syncConfiguration;
            PredicateRootPathResolver = predicateRootPathResolver;
            Evaluator = evaluator;
            Predicate = predicate;
            TargetDataStore = targetDataStore;
            SourceDataStore = sourceDataStore;
        }
 public void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
 {
     increaseLevel(evaluator);
     ListSupport listSupport = new ListSupport(commandCall);
     foreach (ListEntry listEntry in listSupport.GetListEntries())
     {
         commandCall.Element = listEntry.Element;
         if (listEntry.IsItem)
         {
             commandCall.Execute(evaluator, resultRecorder);
         }
         if (listEntry.IsList)
         {
             Execute(commandCall, evaluator, resultRecorder);
         }
     }
     decreaseLevel(evaluator);
 }
Exemple #58
0
        public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'echo' is not supported");

            Object result = evaluator.Evaluate(commandCall.Expression);

            Element element = commandCall.Element;
            if (result != null)
            {
                element.AppendText(result.ToString());
            }
            else
            {
                Element child = new Element("em");
                child.AppendText("null");
                element.AppendChild(child);
            }
        }
        public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported");

            Element element = commandCall.Element;

            object actual = evaluator.Evaluate(commandCall.Expression);
            string expected = element.Text;

            if (m_comparer.Compare(actual, expected) == 0)
            {
                resultRecorder.Record(Result.Success);
                OnSuccessReported(element);
            }
            else
            {
                resultRecorder.Record(Result.Failure);
                OnFailureReported(element, actual, expected);
            }
        }
        public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported");

            Element element = commandCall.Element;

            object actual = evaluator.Evaluate(commandCall.Expression);
            string expected = element.Text;

            if (this.m_Comparer.Compare(actual, expected) == 0)
            {
                resultRecorder.Success();
                AnnounceSuccess(element);
            }
            else
            {
                resultRecorder.Failure(string.Format("expected {0} but was {1}", expected, actual),
                                       element.ToXml());
                AnnounceFailure(element, expected, actual);
            }
        }