public void FunctionRepository_Remove_ValidFunction_Expected_FunctionRemovedFromRepo()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();
            string        functionName = "TestFunction";
            List <string> arguments    = new List <string>()
            {
                "args"
            };
            List <string> argumentDescriptions = new List <string>()
            {
                "the first argument"
            };
            string description = "Test Description";

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();


            IFunction myFunction = MathOpsFactory.CreateFunction(functionName, arguments, argumentDescriptions, description);

            // save the new function
            functionRepo.Save(myFunction);

            functionRepo.Remove(myFunction);

            Assert.AreEqual(0, functionRepo.Find(c => c.FunctionName.Equals(functionName)).Count);
        }
        public void FunctionRepository_SaveCollection_ValidFunction_Expected_RepoUpdatedWithNewFunction()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();
            string        functionName = "TestFunction";
            List <string> arguments    = new List <string>()
            {
                "args"
            };
            List <string> argumentDescriptions = new List <string>()
            {
                "the first argument"
            };
            string description = "Test Description";

            string function2Name = "TestFunction2";

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();


            IFunction myfirstFunction            = MathOpsFactory.CreateFunction(functionName, arguments, argumentDescriptions, description);
            IFunction mySecondFunction           = MathOpsFactory.CreateFunction(function2Name, arguments, argumentDescriptions, description);
            ICollection <IFunction> functionList = new List <IFunction>()
            {
                myfirstFunction, mySecondFunction
            };

            functionRepo.Save(functionList);

            Assert.AreEqual(2, functionRepo.Find(c => c.FunctionName.Contains(functionName)).Count);
        }
Пример #3
0
        public CalculateIntellisenseProvider(ISyntaxTreeBuilderHelper syntaxTreeBuilderHelper)
        {
            _syntaxTreeBuilderHelper = syntaxTreeBuilderHelper;
            IntellisenseProviderType = IntellisenseProviderType.NonDefault;
            IFrameworkRepository <IFunction> functionList = MathOpsFactory.FunctionRepository();

            functionList.Load();
            bool creatingFunctions = false;

            if (_functionNames == null)
            {
                creatingFunctions = true;
                _functionNames    = new HashSet <string>(StringComparer.Ordinal);
            }

            IntellisenseResult = functionList.All().Select(currentFunction =>
            {
                string description         = currentFunction.Description;
                string dropDownDescription = description;
                if (description != null && description.Length > 80)
                {
                    dropDownDescription = description.Substring(0, 77) + "...";
                }
                if (creatingFunctions)
                {
                    _functionNames.Add(currentFunction.FunctionName);
                }
                IntellisenseProviderResult result = new IntellisenseProviderResult(this, currentFunction.FunctionName, dropDownDescription, description, currentFunction.arguments != null ? currentFunction.arguments.ToArray() : new string[0], currentFunction.ArgumentDescriptions != null ? currentFunction.ArgumentDescriptions.ToArray() : new string[0]);
                return(result);
            }).OrderBy(p => p.Name).ToList();
        }
        public void FunctionRepository_Find_NullExpression_Expected_ErrorFromRepository()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();
            ICollection <IFunction> functions = functionRepo.Find(null);
        }
        public void FunctionRepository_Load_DefaultRepository()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            functionRepo.Load();
            IEnumerable <IFunction> functions = functionRepo.All();

            Assert.IsTrue(functionRepo.All().Count > 0);
        }
        public void FunctionRepository_Remove_NullFunction_Expected_ArgumentNullException()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();

            functionRepo.Remove((IFunction)null);
        }
        public void FunctionRepository_FindSingle_ExpressionYieldsNoResult_Expected_EmptyFunctionReturned()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();
            IFunction function = functionRepo.FindSingle(c => c.FunctionName == string.Empty);

            Assert.IsInstanceOfType(function, typeof(IFunction));
        }
        public void FunctionRepository_FindSingle_ValidExpression_Expected_SingleResultReturned()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();

            IFunction function = functionRepo.FindSingle(c => c.FunctionName.Contains("s"));

            Assert.IsNotNull(function);
        }
        public void FunctionRepository_Find_ExpressionYieldsNoResult_Expected_EmptyCollectionReturned()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();

            ICollection <IFunction> functions = functionRepo.Find(c => c.FunctionName == string.Empty);

            Assert.AreEqual(0, functions.Count);
        }
        public void FunctionRepository_RemoveCollection_NullCollection_Expected_ArgumentException()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();
            int beforeEmptySave = functionRepo.Find(c => c.FunctionName != string.Empty).Count;

            functionRepo.Remove((ICollection <IFunction>)null);
            Assert.IsNotNull(beforeEmptySave);
        }
        public void FunctionRepository_Find_ValidExpressionAndReturnsData_Expected_ListReturned()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();

            ICollection <IFunction> functions = functionRepo.Find(c => c.FunctionName.Length > 0);


            Assert.IsTrue(functions.Count > 0);
        }
        public void FunctionRepository_SaveCollection_NullCollection_Expected_ArgumentNullException()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();
            int beforeEmptySave = functionRepo.Find(c => c.FunctionName != string.Empty).Count;

            ICollection <IFunction> functionList = null;

            functionRepo.Save(functionList);
        }
        public void FunctionRepository_RemopveCollection_EmptyCollection_Expected_NoFunctionsRemovedFromRepo()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();
            int beforeEmptySave = functionRepo.Find(c => c.FunctionName != string.Empty).Count;

            ICollection <IFunction> functionList = new List <IFunction>();

            functionRepo.Remove(functionList);

            int afterEmptySave = functionRepo.Find(c => c.FunctionName != string.Empty).Count;

            Assert.AreEqual(beforeEmptySave, afterEmptySave);
        }
        public void FunctionRepository_RemoveCollection_ValidFunction_Expected_RepoUpdatedWithNewFunction()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();


            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();
            ICollection <IFunction> functionsToRemove = functionRepo.Find(c => c.FunctionName.Contains("s"));
            int functionCountBeforeRemove             = functionRepo.Find(c => c.FunctionName != string.Empty).Count;

            functionRepo.Remove(functionsToRemove);

            int functionCountAfterRemove = functionRepo.Find(c => c.FunctionName != string.Empty).Count;

            Assert.IsTrue(functionCountAfterRemove < functionCountBeforeRemove);
        }
Пример #15
0
        private void InitializeWebResources()
        {
            _webResources = WebResourceRepositoryFactory.CreateWebResourceRepository(_resource);
            _webResources.Load();

            if (_webResources == null)
            {
                throw new InvalidOperationException("WebResourceFactory returned null repository");
            }

            _rootWebResource = new WebResourceViewModel(null)
            {
                Name = "root", IsRoot = true
            };
            _webResources.All().ToList().ForEach(c => _rootWebResource.Children.Add(c));
        }
        public void FunctionRepository_Save_NullFunction_Expected_ArgumentNullException()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();

            try
            {
                functionRepo.Save((IFunction)null);
            }
            catch (ArgumentNullException)
            {
                // If there was a null argument exception, it's behaving
                Assert.IsTrue(true);
            }
        }
Пример #17
0
 public FrameworksImportService(
     IJsonFileHelper jsonFileHelper,
     IImportAuditRepository importAuditRepository,
     IFrameworkImportRepository frameworkImportRepository,
     IFrameworkFundingImportRepository frameworkFundingImportRepository,
     IFrameworkRepository frameworkRepository,
     IFrameworkFundingRepository frameworkFundingRepository,
     ILogger <FrameworksImportService> logger)
 {
     _jsonFileHelper                   = jsonFileHelper;
     _importAuditRepository            = importAuditRepository;
     _frameworkImportRepository        = frameworkImportRepository;
     _frameworkFundingImportRepository = frameworkFundingImportRepository;
     _frameworkRepository              = frameworkRepository;
     _frameworkFundingRepository       = frameworkFundingRepository;
     _logger = logger;
 }
Пример #18
0
        private static void InitMathFnRawData()
        {
            IFrameworkRepository <IFunction> repo = FunctionRepository();

            repo.Load();
            ICollection <IFunction> fns = repo.All();
            StringBuilder           tmp = new StringBuilder("<DL>");

            // build list
            foreach (IFunction f in fns)
            {
                _rawMathFnList.Add(f.FunctionName);
                tmp.Append("<");
                tmp.Append(f.FunctionName);
                tmp.Append("/>");
            }
            tmp.Append("</DL>");

            _mathFnDataList = tmp.ToString();
        }
        public void FunctionRepository_Save_ValidFunction_Expected_RepoUpdatedWithNewFunction()
        {
            IFrameworkRepository <IFunction> functionRepo = MathOpsFactory.FunctionRepository();
            const string  functionName = "TestFunction";
            List <string> arguments    = new List <string> {
                "args"
            };
            List <string> argumentDescriptions = new List <string> {
                "the first argument"
            };
            const string description = "Test Description";

            // The function repository must be loaded in order to populate the function list
            functionRepo.Load();


            IFunction myFunction = MathOpsFactory.CreateFunction(functionName, arguments, argumentDescriptions, description);

            functionRepo.Save(myFunction);

            Assert.IsNotNull(functionRepo.Find(c => c.FunctionName.Equals(functionName)));
        }
 public FrameworksService(IFrameworkRepository frameworkRepository)
 {
     _frameworkRepository = frameworkRepository;
 }
Пример #21
0
 public FrameworksController(IFrameworkRepository repository) : base(repository)
 {
 }
Пример #22
0
 public SampleDataController(IFrameworkRepository repository)
 {
     _repository = repository;
 }
Пример #23
0
        private void InitializeWebResources()
        {
            _webResources = WebResourceRepositoryFactory.CreateWebResourceRepository(_resource);
            _webResources.Load();

            if(_webResources == null)
            {
                throw new InvalidOperationException("WebResourceFactory returned null repository");
            }

            _rootWebResource = new WebResourceViewModel(null) { Name = "root", IsRoot = true };
            _webResources.All().ToList().ForEach(c => _rootWebResource.Children.Add(c));
        }
Пример #24
0
 public FrameworkService(IFrameworkRepository frameworkRepository, IProgrammingLanguageRepository programmingLanguageRepository)
 {
     _frameworkRepository           = frameworkRepository;
     _programmingLanguageRepository = programmingLanguageRepository;
 }