Example #1
0
        public void CalculateTheCorrectOutput_WhenValidDoubleArgumentsArePassed(double seed, double output)
        {
            var evaluator = new Evaluator <double>();

            evaluator.Add((val, _) => val / 2);
            evaluator.Add((val, additionalVals) => val + additionalVals[0], 5);
            evaluator.Add((val, additionalVals) => val + 1 + additionalVals[0], 20);
            evaluator.Add((val, additionalVals) => val - additionalVals[0] - additionalVals[1], 5, 3);

            evaluator.Evaluate(seed).Should().Be(output);
        }
Example #2
0
        public void ThrowDivideByZeroException_WhenDivideByZeroOperationIsAttempted()
        {
            var evaluator = new Evaluator <int>();

            evaluator.Add((val, _) => val / 0);

            Assert.Throws <DivideByZeroException>(() => evaluator.Evaluate(8));
        }
Example #3
0
        private static void EvaluateFileExtension(VfsFile file, Evaluator evaluator)
        {
            var extension = Path.GetExtension(file.FullPath);

            foreach (var type in FileTypeDatabase.GetFileTypesByExtension(extension))
            {
                evaluator.Add(type, POINTS_EXTENSION);
            }
        }
Example #4
0
        public void DoesNotThrowArgumentNullException_WhenNullArgsIsPassed()
        {
            var evaluator = new Evaluator <int>();

            Assert.DoesNotThrow(() => evaluator.Add((val, _) => val / 4));
        }
Example #5
0
        public void ThrowArgumentNullException_WhenNullFuncIsPassed()
        {
            var evaluator = new Evaluator <int>();

            Assert.Throws <ArgumentNullException>(() => evaluator.Add(null, 1));
        }