public void Execute_ExceptionThrowingCommand_ReturnsFalse() { var logdirector = new Mock<ILogger>(); var executecommand = new Mock<IExecuteCommand>(); executecommand.Setup(foo => foo.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)).Throws(new Exception("Test Exception")); var objectUnderTest = new ExecuteCommandOnCollection(logdirector.Object); objectUnderTest.Commands.Add(executecommand.Object); Assert.IsFalse(objectUnderTest.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)); }
public void Execute_ExceptionThrowingCommand_LogsError() { var logdirector = new Mock<ILogger>(); logdirector.Setup(foo => foo.Error(It.IsRegex("Exception in Execute"))); var executecommand = new Mock<IExecuteCommand>(); executecommand.Setup(foo => foo.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)).Throws(new Exception("Test Exception")); var objectUnderTest = new ExecuteCommandOnCollection(logdirector.Object); objectUnderTest.Commands.Add(executecommand.Object); objectUnderTest.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero); logdirector.VerifyAll(); }
public DefaultLoader(RunCommandOnCollection runCommand, ExecuteCommandOnCollection executeCommand, ExecuteBackgroundCommandOnCollection executeBackgroundCommand, ReloadCommandOnCollection reloadCommand, AssemblyResolver resolver, DefaultModuleDirectorySupervisor directorySupervisor, ILoggerContainer logger) { this.logger = logger; this.directorySupervisor = directorySupervisor; this.resolver = resolver; this.reloadCommand = reloadCommand; this.executeBackgroundCommand = executeBackgroundCommand; this.executeCommand = executeCommand; this.runCommand = runCommand; }
public void Execute_MultipleCommands_RunsAll() { var logdirector = new Mock<ILogger>(); var executecommand1 = new Mock<IExecuteCommand>(); executecommand1.Setup(foo => foo.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)).Returns(true); var executecommand2 = new Mock<IExecuteCommand>(); executecommand2.Setup(foo => foo.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)).Returns(true); var objectUnderTest = new ExecuteCommandOnCollection(logdirector.Object); objectUnderTest.Commands.Add(executecommand1.Object); objectUnderTest.Commands.Add(executecommand2.Object); Assert.IsTrue(objectUnderTest.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)); executecommand1.VerifyAll(); executecommand2.VerifyAll(); }
public void Execute_Empty_ReturnsTrue() { var logdirector = new Mock<ILogger>(); var objectUnderTest = new ExecuteCommandOnCollection(logdirector.Object); Assert.IsTrue(objectUnderTest.Execute(string.Empty, IntPtr.Zero, IntPtr.Zero)); }
public void ClassContainsCommandsCollection() { var logdirector = new Mock<ILogger>(); var objectUnderTest = new ExecuteCommandOnCollection(logdirector.Object); Assert.IsNotNull(objectUnderTest.Commands); }