예제 #1
0
        public void GetFunctionForInvalidFunctionTest()
        {
            var functionRepository = FunctionRepository.Create();
            var function           = functionRepository.GetFunction("NOTAFUNCTION");

            Assert.IsNull(function);
        }
예제 #2
0
        public void GetFunctionTest()
        {
            var functionRepository = FunctionRepository.Create();
            var function           = functionRepository.GetFunction("ABS");

            Assert.IsNotNull(function);
            Assert.IsTrue(function is Abs);
        }
예제 #3
0
        public void GetFunctionWithXlfnPrefix()
        {
            var functionRepository = FunctionRepository.Create();
            var function           = functionRepository.GetFunction("_xlfn.IF");

            Assert.IsNotNull(function);
            Assert.IsTrue(function is If);
        }
예제 #4
0
        public void CreateHandlesErrorFunctionCompiler()
        {
            var functionRepository      = FunctionRepository.Create();
            var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context);
            var function         = new IsError();
            var functionCompiler = functionCompilerFactory.Create(function);

            Assert.IsInstanceOfType(functionCompiler, typeof(ErrorHandlingFunctionCompiler));
        }
예제 #5
0
        public void CreateHandlesLookupFunctionCompiler()
        {
            var functionRepository      = FunctionRepository.Create();
            var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context);
            var function         = new Column();
            var functionCompiler = functionCompilerFactory.Create(function);

            Assert.IsInstanceOfType(functionCompiler, typeof(LookupFunctionCompiler));
        }
예제 #6
0
        public void CreateHandlesSpecialIfNaCompiler()
        {
            var functionRepository      = FunctionRepository.Create();
            var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context);
            var function         = new IfNa();
            var functionCompiler = functionCompilerFactory.Create(function);

            Assert.IsInstanceOfType(functionCompiler, typeof(IfNaFunctionCompiler));
        }
예제 #7
0
        public void CreateHandlesStandardFunctionCompiler()
        {
            var functionRepository      = FunctionRepository.Create();
            var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context);
            var function         = new Sum();
            var functionCompiler = functionCompilerFactory.Create(function);

            Assert.IsInstanceOfType(functionCompiler, typeof(DefaultCompiler));
        }
예제 #8
0
        public void CreateHandlesCustomFunctionCompiler()
        {
            var functionRepository = FunctionRepository.Create();

            functionRepository.LoadModule(new TestFunctionModule(_context));
            var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context);
            var function         = new MyFunction();
            var functionCompiler = functionCompilerFactory.Create(function);

            Assert.IsInstanceOfType(functionCompiler, typeof(MyFunctionCompiler));
        }
예제 #9
0
        public void LoadModulePopulatesFunctionsAndCustomCompilers()
        {
            var functionRepository = FunctionRepository.Create();

            Assert.IsFalse(functionRepository.IsFunctionName(MyFunction.Name));
            Assert.IsFalse(functionRepository.CustomCompilers.ContainsKey(typeof(MyFunction)));
            functionRepository.LoadModule(new TestFunctionModule());
            Assert.IsTrue(functionRepository.IsFunctionName(MyFunction.Name));
            Assert.IsTrue(functionRepository.CustomCompilers.ContainsKey(typeof(MyFunction)));
            // Make sure reloading the module overwrites previous functions and compilers
            functionRepository.LoadModule(new TestFunctionModule());
        }
예제 #10
0
 private ParsingConfiguration()
 {
     FunctionRepository = FunctionRepository.Create();
 }