Beispiel #1
0
        public void ReturnsCorrectResult()
        {
            var context = CreateCommandContext();

            var command = new FakeCommand(FakeReturnValue);

            command.Execute(context);

            Assert.AreEqual(FakeReturnValue, command.Result);
        }
Beispiel #2
0
        public void OnExecuteIsCalledWhenExecuting()
        {
            var context = CreateCommandContext();

            var command = new FakeCommand(FakeReturnValue);

            command.Execute(context);

            Assert.True(command.OnExecuteCalled);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }