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); }
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_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); }
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_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_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))); }