public void ReturnsCorrectResult() { var context = CreateCommandContext(); var command = new FakeCommand(FakeReturnValue); command.Execute(context); Assert.AreEqual(FakeReturnValue, command.Result); }
public void OnExecuteIsCalledWhenExecuting() { var context = CreateCommandContext(); var command = new FakeCommand(FakeReturnValue); command.Execute(context); Assert.True(command.OnExecuteCalled); }
public void OnExecute_Is_Called_When_Executing() { var transaction = new Mock<ITransaction>(); var session = new Mock<ISession>(); session.Setup(s => s.BeginTransaction()).Returns(() => transaction.Object); var context = new CommandContext(session.Object, null); var command = new FakeCommand(); command.Execute(context); Assert.True(command.OnExecuteCalled); }
public void OnExecute_Is_Called_When_Executing() { var transaction = new Mock <ITransaction>(); var session = new Mock <ISession>(); session.Setup(s => s.BeginTransaction()).Returns(() => transaction.Object); var context = new CommandContext(session.Object, null); var command = new FakeCommand(); command.Execute(context); Assert.True(command.OnExecuteCalled); }
public void OnException_Is_Called_When_Commit_Throws_Exception() { var transaction = new Mock<ITransaction>(); transaction.Setup(t => t.Commit()).Throws<NHibernate.Exceptions.GenericADOException>(); var session = new Mock<ISession>(); session.Setup(s => s.BeginTransaction()).Returns(() => transaction.Object); var context = new CommandContext(session.Object, null); var command = new FakeCommand(); command.Execute(context); Assert.True(command.OnExecuteCalled); Assert.True(command.OnExceptionCalled); }
public void OnException_Is_Called_When_Commit_Throws_Exception() { var transaction = new Mock <ITransaction>(); transaction.Setup(t => t.Commit()).Throws <NHibernate.Exceptions.GenericADOException>(); var session = new Mock <ISession>(); session.Setup(s => s.BeginTransaction()).Returns(() => transaction.Object); var context = new CommandContext(session.Object, null); var command = new FakeCommand(); command.Execute(context); Assert.True(command.OnExecuteCalled); Assert.True(command.OnExceptionCalled); }