The Liberator

Tags

, , , , , , ,

king-dan

Not many people today have heard of Daniel O’Connell, but it is said he’s the father of the civil rights movement, someone commonly compared by historians to Ghandi and Martin Luther King, and a celebrity across Europe during his time. He made quite an impression on Charles Dickens (and the novel Martin Chuzzlewit).
O’Connell was, at one point, crowned ‘King of Ireland’ in front of roughly 750,000 people at the hill of Tara. More recently, his name found its way into the speeches of Elizabeth Windsor and President Obama.

I wondered, as a strong believer (less a campaigner these days) in civil rights myself, who exactly was this man? More to the point, how did he warrant the title of ‘The Liberator’?
To answer these questions, I swiped a biography by Patrick Geoghegan. King Dan: The Rise and Fall of Daniel O’Connell is fairly dense, meticulously researched and based around O’Connell’s own journal entries. In all, I think it was excellently authored.

Early Life and Personality
Daniel O’Connell is, before anything, most commonly credited with leading one of the very first mass civil rights movements, and was certainly not a revolutionary. In his early years, he witnessed first-hand the aftermath of the French Revolution, and was a target himself, being an aristocrat and with an uncle being a general serving Louis XVI. His loyalties lay with the establishment until his final years. And O’Connell had the foresight to understand that revolutions almost invariably result in more bloodshed, brutality and oppression.

As for personality, O’Connell had a couple of traits that are instantly recognisable: According to those who met him, he was very warm, humourous, compassionate and generous – quite a generic statement that could apply to anyone, but his generosity appears a main reason he was heavily in debt most his life. In the courtrooms and among other politicians, he easily deployed sarcasm, wit, insolence, colourful insults, inventive ways of exposing untruths and comedy with great effect.

O’Connell would stick to his principles and wouldn’t back down under pressure. It was his way or the highway. When everyone around him believed concessions and negotiation was the only route to equality for Irish Catholics, O’Connell remained insistent on fighting for a full and immediate repeal of the Acts of Union.

He was also absolute in his advocacy of libertarianism, calling out the hypocrisy of slavery in America and joining the protestant evangelists in the anti-slavery cause – something Geoghegan’s other book might cover in more detail. Unfortunately there isn’t a lot about whether O’Connell did much to extend the fight to the working classes, as Young Ireland and the Chartists did.

The Politics
Sadly Geoghegan’s book also doesn’t give enough attention to the people who weren’t among the politicians and aristocrats, so it’s hard to tell just from this book how many Catholics genuinely saw hope in O’Connell’s ideas. Was he fighting to end a situation in which many Irish people were prepared to earn citizenship in America through years of back-breaking servitude? Did he think Catholic emancipation would ultimately be critical in fighting poverty?

Religion did play a major part, because the law was rigged in favour of the Protestants, there just happened to be a geographic division, and because O’Connell used the network of churches to mobilise supporters outside the small circle of people he associated with. Ultimately it was a political thing, centred around the Acts of Union that abolished the Irish parliament.

There were several other people leading the Catholic emancipation movement, which was already growing by the time O’Connell became involved. There were committee meetings, board meetings and more committee meetings, until disagreements led to O’Connell forming a Catholic Association. There wasn’t a coherent direction up until that point.

The Catholic Association
Which brings us to the legendary Catholic Association and the Order of Liberators that O’Connell is best remembered for.

Right up until 1823, the talks of Catholic emancipation were between O’Connell’s peers, a handful of politicians, lawyers, judges, etc. etc. It wasn’t until then, when O’Connell was around 48 years of age, and already a celebrity lawyer, that he reached out to the wider population for support.

What he did next was to use the network of Catholic churches in Ireland to build support and funding. At one point the Catholic Association also operated a kind of welfare system off the books, to undermine the power landlords had over the tenants.

There’s a lot more to be said about the Catholic Association, but here Geoghegan’s biography ends, with the later events covered in another book.
My current understanding is O’Connell’s fame and following grew over the years. A series of ‘monster meetings’ were held around Ireland, culminating in the 750,000-strong rally near the hill at Tara in 1843. Here O’Connell was crowned ‘King of Ireland’, which I suspect was staged by O’Connell himself to provoke the establishment.

And that was that. The Tara rally scared The Powers That Be enough to mobilise regiments and warships, and threaten to massacre anyone who attended the next ‘monster meeting’. O’Connell backed down, but was still jailed for sedition.
By the time he was released, the movement was demoralised, but a few Young Irelanders continued fighting a related class struggle.

I think it was Frederick Engels who wrote of O’Connell in 1843:
‘The cunning old fox is going from town to town, always accompanied by a bodyguard such as no king ever had – two hundred thousand people always surround him! How muh could have been done if a sensible man possessed O’Connell’s popularity or if O’Connell had a little more understanding, and a little less egoism and vanity!’

And I agree. Had the movement been leaderless and self-organising, as it could easily have become, things would have turned out very differently. The impoverished could have introduced demands that improved their own quality of life, people would have gained the confidence to continue where O’Connell left off. There was a radical faction within O’Connell’s movement, calling themselves Young Ireland, who did precisely that, seeing a class conflict at play.

C#, Shared Libraries and DLLs

Tags

, , , , ,

Starting out with a basic Windows Form application, with variables declared in a public class called ‘OurColours’, the private class for each button is something like:

private void cmdRed_Click(object sender, EventArgs e)
{
txtSelected.Text = OurColours.red;
}

When the button is clicked the string in OurClass is displayed in the text box (txtSelected). But variables don’t need to exist in the same source file. They can exist in a shared object, as demonstrated in my previous post. Just as before, I’ve added a new Class Library project to the solution.

add-new-class-library-project

The new Class Library uses the GlobalParameters namespace, and the public class (userDefined) is copied into it:

parameters-within-file

Returning to the first project where the form was created, we add the GlobalParameters namespace to its references.

add-reference-to-colours-1

Now the code in each form button can be modified to point to variables in GlobalParameters.userDefined. e.g.

private void button4_Click(object sender, EventArgs e)
{
txtSelected.Text = GlobalParameters.userDefined.orange;
}

Writing to the Shared Object
A shared object also enables communication between forms. Within GlobalParameters.userDefined I added another variable called ‘lastSelected‘:
public static string lastSelected;

Then I added another line to each form button code, so it became like:
private void cmdBlue_Click(object sender, EventArgs e)
{
txtSelected.Text = GlobalParameters.userDefined.blue;
GlobalParameters.userDefined.lastSelected = txtSelected.Text + " was selected";
}

Finally I added another form that displays whatever string was passed to GlobalParameters.userDefined.lastSelected. This form has just one label (lblLastSelected), and the text is determined by adding the following after the InitializeComponent() line:
lblLastSelected.Text = GlobalParameters.userDefined.lastSelected;

And here is the finished article:

colours-application-running

As a final note, we can add another class in the shared library, if ever the variables need to be grouped. To do this, simply add a new public class. The variables here are then referred to using GlobalParameters.newVariableGroup.[variable name].

second-variable-class

Also, we might want to make the application portable, distributing it with the shared C# class as a Dynamic Link Library (DLL). This can be done by right-clicking the GlobalParameters References entry for the project, and setting its Copy Local property to ‘True’.

references-copy-property

Download Visual Studio project…

Create a Shared C# Object

Tags

, , ,

Finally I’ve cracked the CSV file problem, sort of, by creating a file that’s shared across multiple Visual C# projects. It took some debugging and trial-and-error, but it works, and it could be applied to other situations where multiple projects need to access a shared C# class. The following method is also way easier than the CSV thing.

As the starting point, we’ll assume a solution with several projects has already been created. Right-click on the root entry in the Solution Explorer, and add a new Class Library project to the solution.

create-empty-class

An empty C# class is automatically generated by default. The first task is to create a namespace that other projects will reference the variables from. Change the autogenerated class to a ‘public static class’, and add a few variables inside it. Personally I’m declaring everything as a ‘public static string’.

In my case, one of the variables uses the Playback.EncryptText() function, which is called from Microsoft.VisualStudio.TestTools, so that library must be imported. When done, the code should look something like:

newclass

Additionally the imports also require ‘assembly references’. Right-click on the References entry for the C# item in Solution Explorer, then select ‘Add Reference…’.

add-reference

The Reference Manager will display an exhaustive list of libraries available to Visual Studio, and we want to find those with the same namespaces as the imports. For example, as I’ve imported Microsoft.VisualStudio.TestTools.UITesting, I want to select that in the Reference Manager.

referenceManager

At this point, we now have a C# class storing variables accessible to all the projects. The next step is to point those projects to the object.

The projects access the shared C# class/object in almost the same way they access Visual Studio’s library objects. Each therefore requirees an assembly reference to the shared C# file and pointers to its namespace.
For each project in the Solution Explorer, add a reference to the namespace. This will be listed in the Solution menu in the Reference Manager.

referenceManager-our-namespace

Finally the project’s source can be modified to actually use the namespace and access the global/public variables. e.g.

calling-parameters

Now all that’s left to clean up by removing the old variable declarations within the individual projects.

Screw the CSV File!

Tags

, , , , , , , , ,

Having messed up some test projects in trying read values from CSV files, and emulating several online tutorials, I decided to try a different approach. A Coded UI Test project directory has UIMap.Designer.cs, which does pretty much the same thing as the CSV file, so why not edit that instead?

changeuimapvalues

The easiest way of altering the parameters it contains is by double-clicking the UIMap.uitest entry in the Solution Explorer and changing the values in the Properties window.

uimap-parameters

The less convenient way of changing the parameters is by modifying the lines in UIMap.Designer.cs. It doesn’t work with passwords, though – these are stored in an encrypted form, and replacing it with a plaintext value would break the test script. Any new password must be encrypted beforehand.

uimap-encrypted-password

Fortunately I din’t have to write a function for that, as Microsoft already provides one: Playback.EncryptText(). Simply use this, and change the variable passed to this function from the UIMap.Designer.cs.

editedpasswordline

But the whole point of adding a CSV file was to make it easier for others to change the test parameters. The next best thing is having all the variables declared near the head of UIMap.Designer.cs. Why not create another partial public class, and have the script reference that instead of this.[Method]Params class?

Just above the [GeneratedCode] in UIMap.Designer.cs, I inserted the following:

OurPublicClass

And changed the variables in the other class to reference them:

ourPrivateClass

How to Load Test with Visual Studio

Tags

, , , , , , , , ,

This is very different to the coded UI tests that I covered last week, and the process isn’t quite as straightforward.

The following are required:
* Visual Studio (Ultimate)
* Visual Studio Online account or Team Foundation Server

Setting Up
A load test uses a ‘Team Foundation Server’ (TFS), which is either an individual installation or obtained by registering a Visual Studio Online account at https://visualstudio.com.
When that’s sorted, sign into the TFS by clicking the icon at the top-right of the Visual Studio environment.

connect-to-team-server-2

The project details will appear in Team Explorer window, where the Solution Explorer normally is.

team-explorer-1

Creating a Web Performance Testing Session
A Web Performance Test Project must be set up before any load testing is done. In Visual Basic or Visual C#, navigate to ‘Test’ and select ‘Web Performance and Load Test Project’. The Solution Explorer will re-appear. Add a Web Performance Test to the project.

new-web-performance-project

add-web-performance-test-project

Visual Studio should automatically begin recording the Internet Explorer session, unless an existing project is selected and the Add Recording button is clicked. The Microsoft Web Test Recorder browser add-on must be enabled at this point.

web-performance-recording

When finished, click the Stop Recording button. The steps will be displayed in the main window, and can be replayed using the Run Test button above.
A successful run will produce output similar to the following example:

web-performance-test-complete

The Load Test
With a recorded Web test session, the project should be ready for a load test. This time, add a Load Test to the project. This will start the New Load Test Wizard – this is where the ‘load test scenario’ is created and the Web test scripts imported.

create-load-test-scenario

When the dialogue closes, a tree structure will appear in Visual Studio’s main window. With a bit of luck Visual Studio will connect to the right server, queue the test and execute it when the Run Test icon is clicked.

load-test-connecting-to-server

Analysing the Results
But how to get the metrics and flashy graphs we’re after? Simple: Just double-click the load test name to get the tree structure in the main window, then click the Open and Manage Results button at the top-left.

open-manage-results-button

In the Open and Manage Load Test Results, click ‘Open…’, and the metrics will appear in Visual Studio’s main window.

load-test-metrics

Follow

Get every new post delivered to your Inbox.

Join 25 other followers