Esempio n. 1
0
        public void FailToCreateModulesFromNullDirectory()
        {
            var factory = new CalculatorModuleFactory();

            Assert.Throws <ArgumentNullException>(() =>
            {
                var module = factory.CreateFromDirectories(null);
            });
        }
Esempio n. 2
0
        public void FailToCreateModulesFromEmptyDirectory()
        {
            var factory = new CalculatorModuleFactory();

            Assert.Throws <ArgumentException>(() =>
            {
                var module = factory.CreateFromDirectories(string.Empty);
            });
        }
Esempio n. 3
0
        public void FailToCreateModulesFromSingleRelativePathDirectory()
        {
            var factory = new CalculatorModuleFactory();

            Assert.Throws <ArgumentException>(() =>
            {
                var module = factory.CreateFromDirectories(Definitions.CalculatorDirectory);
            });
        }
Esempio n. 4
0
        public void SuccessfullyCreateModulesFromSingleAbsolutePathDirectory()
        {
            var factory = new CalculatorModuleFactory();

            var directory = Path.GetFullPath(Definitions.CalculatorDirectory);

            var module = factory.CreateFromDirectories(directory);

            Assert.NotNull(module);
            Assert.NotEmpty(module);
        }
        private static void LoadRepository(CalculatorRepository repository, string calculatorDirectory)
        {
            var factory = new CalculatorModuleFactory();
            var modules = factory.CreateFromDirectories(calculatorDirectory);

            foreach (var module in modules)
            {
                System.Diagnostics.Trace.WriteLine($"Loaded module: {module.Function.FunctionInfo.Name}");
            }

            var id = 0;

            repository.UpdateStore(modules.Select(i => new Calculator(++id, i)));
        }