public void TestInitialize()
        {
            _tableControllerShadow = new TableControllerShadow();
            _tableExists = (x, session) => true;
            _updateMethod = (x, y, z) => { };

            _session = Substitute.For<ISession>();
            _sessionMethod = () => _session;

            _methodGroup = new UpdateTableDescriptionMethodGroup(_tableExists, _updateMethod, _sessionMethod);
        }
예제 #2
0
        public JsonResult UpdateTableDescription(int id, string description, UpdateTableDescriptionMethodGroup methodGroup)
        {
            new WithSession(methodGroup.SessionMethod)
                .Do(session =>
                    {
                        GuardClause.IfFalseThenThrowArgumentException(() => methodGroup.TableExists(id, session), "TableControllerShadow.UpdateTableDescription: Table doesn't exist.");
                        methodGroup.UpdateMethod(id, description, session);
                    });

            return new JsonResult {Data = description};
        }
 public void TheUpdateMethodIsCalledCorrectly()
 {
     _methodGroup = new UpdateTableDescriptionMethodGroup(_tableExists, (x, y, session) => { if (x == TableId && session == _session) throw new MethodAccessException(); }, _sessionMethod);
     AssertionExtensions.ShouldThrow<MethodAccessException>(() => _tableControllerShadow.UpdateTableDescription(TableId, Description, _methodGroup));
 }
 public void TheTableDoesNotExistSoAnExceptionIsThrown()
 {
     _tableExists = (x, session) => false;
     _methodGroup = new UpdateTableDescriptionMethodGroup(_tableExists, _updateMethod, _sessionMethod);
     AssertionExtensions.ShouldThrow<ArgumentException>(() => _tableControllerShadow.UpdateTableDescription(TableId, Description, _methodGroup));
 }
 public void AndTheTableQueryIsCalledCorrectly()
 {
     _methodGroup = new UpdateTableDescriptionMethodGroup((x, session) => { if (session == _session) throw new MethodAccessException(); return false; }, _updateMethod, _sessionMethod);
     AssertionExtensions.ShouldThrow<MethodAccessException>(() => _tableControllerShadow.UpdateTableDescription(TableId, Description, _methodGroup));
 }
 public void AndANewSessionIsCreated()
 {
     _methodGroup = new UpdateTableDescriptionMethodGroup(_tableExists, _updateMethod, () => { throw new MethodAccessException(); });
     AssertionExtensions.ShouldThrow<MethodAccessException>(() => _tableControllerShadow.UpdateTableDescription(TableId, Description, _methodGroup));
 }