Пример #1
0
        public void edit_deleted_table_failed()
        {
            var deletedTable = new Table();

            typeof(VersionableEntity)
            .GetProperty("IsDeleted")
            .SetValue(deletedTable, true);

            UnitOfWorkMock.Get <Table>(Arg.Any <int>()).Returns(deletedTable);
            _blockMock = true;

            Assert.Throws <InvalidOperationException>(() => Execute());
        }
Пример #2
0
        public void edit_not_newest_table_failed()
        {
            var notNewestTable = new Table();

            typeof(VersionableEntity)
            .GetProperty("IsNewest")
            .SetValue(notNewestTable, false);

            UnitOfWorkMock.Get <Table>(Arg.Any <int>()).Returns(notNewestTable);
            _blockMock = true;

            Assert.Throws <InvalidOperationException>(() => Execute());
        }
Пример #3
0
        private void Execute(EditTableCommand command)
        {
            if (!_blockMock)
            {
                UnitOfWorkMock.Get <Table>(Arg.Any <int>()).Returns(Edited);
                UnitOfWorkMock.Add(Arg.Any <Type>(), Arg.Any <Table>()).Returns(Edited);
                UnitOfWorkMock.Add(Arg.Any <Type>(), Arg.Any <User>()).Returns(EditedUser);
            }
            var handler = new EditTableHandler()
            {
                UnitOfWork = UnitOfWorkMock
            };

            handler.Handle(command);
        }