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()); }
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()); }
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); }