public void AddFunction_TestNullName(IClFunction function) { function.Name = null; _consoleParser.Invoking(x => x.AddFunction(function)) .ShouldThrow<InvalidOperationException>(); }
public void AddFunction(IClFunction function) { if (function == null) throw new ArgumentNullException(nameof(function)); //Check for invalid names if (String.IsNullOrWhiteSpace(function.Name)) { throw new InvalidOperationException("List cannot contain functions with invalid names"); } _functions.Add(function); }
public void ExecuteArguments_TestDiffArgsLengths(IClFunction function1, IClFunction function2) { function1.Name = "test"; function2.Name = "test2"; _consoleParser.AddFunctions(new List<IClFunction> { function1, function2 }); _consoleParser.ExecuteArguments(new[] { "test2", "dkjdkjd", "dlkdlkdlkd" }); }
public void ExecuteArguments_TestExecuteNotCalledForInvalidName(IClFunction function1, IClFunction function2) { function1.Name = "test"; function2.Name = "test2"; _consoleParser.AddFunctions(new List<IClFunction> { function1, function2 }); _consoleParser.ExecuteArguments(new[] { "test3" }); function1.DidNotReceive().Execute(); }
public void ExecuteArguments_TestExecuteNotCalledAfterSecondAdd(IClFunction function1, IClFunction function2) { function1.Name = "test"; function2.Name = "test2"; _consoleParser.AddFunction(function1); _consoleParser.AddFunction(function2); _consoleParser.ExecuteArguments(new[] { "test2" }); function1.DidNotReceive().Execute(); }
public void ExecuteArguments_TestExecuteCalledAfterAddList(IClFunction function1, IClFunction function2) { function1.Name = "test"; function2.Name = "test2"; _consoleParser.AddFunctions(new List<IClFunction> { function1, function2 }); _consoleParser.ExecuteArguments(new[] { "test2" }); function2.Received(1).Execute(); }
public void ExecuteArguments_TestExecuteCalled(IClFunction function) { function.Name = "test"; _consoleParser.AddFunction(function); _consoleParser.ExecuteArguments(new[] { "test" }); function.Received(1).Execute(); }