public void Reload_ExceptionThrowingCommand_ReturnsFalse() { var logdirector = new Mock<ILogger>(); var runcommand = new Mock<IReloadCommand>(); runcommand.Setup(foo => foo.Reload(string.Empty)).Throws(new Exception("Test Exception")); var objectUnderTest = new ReloadCommandOnCollection(logdirector.Object); objectUnderTest.Commands.Add(runcommand.Object); Assert.IsFalse(objectUnderTest.Reload(string.Empty)); }
public void Reload_ExceptionThrowingCommand_LogsError() { var logdirector = new Mock<ILogger>(); logdirector.Setup(foo => foo.Error(It.IsRegex("Error reloading"))); var runcommand = new Mock<IReloadCommand>(); runcommand.Setup(foo => foo.Reload(string.Empty)).Throws(new Exception("Test Exception")); var objectUnderTest = new ReloadCommandOnCollection(logdirector.Object); objectUnderTest.Commands.Add(runcommand.Object); objectUnderTest.Reload(string.Empty); logdirector.VerifyAll(); }
public void Reload_MultipleCommands_RunsAll() { var logdirector = new Mock<ILogger>(); var runcommand1 = new Mock<IReloadCommand>(); runcommand1.Setup(foo => foo.Reload(string.Empty)).Returns(true); var runcommand2 = new Mock<IReloadCommand>(); runcommand2.Setup(foo => foo.Reload(string.Empty)).Returns(true); var objectUnderTest = new ReloadCommandOnCollection(logdirector.Object); objectUnderTest.Commands.Add(runcommand1.Object); objectUnderTest.Commands.Add(runcommand2.Object); objectUnderTest.Reload(string.Empty); runcommand1.VerifyAll(); runcommand2.VerifyAll(); }
public void Reload_Empty_ReturnsTrue() { var logdirector = new Mock<ILogger>(); var objectUnderTest = new ReloadCommandOnCollection(logdirector.Object); Assert.IsTrue(objectUnderTest.Reload(string.Empty)); }