Bookmarklets gone Awry in Firefox

Bookmarklets are simple, right? You put a snippet of javascript into a bookmark prepended by ‘javascript:’, and then you can click your bookmark to do some javascript magic on your page. For example, if you create a bookmark with this URL (Basic Bookmarklet Demo):

1
javascript:alert('Hello World');

You will see a ‘Hello World’ alert when you click the bookmark (don’t forget to turn on your bookmark toolbar in your web browser so you have a place to put your bookmarklets).

There are all sorts of interesting bookmarklets out there. You can have bookmarklets that help you analyze your DOM, clean up a page to make it more readable, or even share on Facebook.

However, as with all things related to web development, things don’t always work the same on all web browsers. I was recently working with a bookmarklet that needed to wait until the page was finished loading before it did anything, so I used the setTimeout method, like this (Broken Bookmarklet Demo{alert( “Demo for Broken Bookmarklet - drag to bookmarks bar to test”)):

Read More

Node.js and the Windows Azure Accelerator for Web Roles

Windows Azure Accelerator for Web Roles
Azure is a great platform to build applications on, and it allows you to scale up very high without a huge investment in infrastructure. However, what if you want to use Azure to scale down very low? What do you do if you want to run 20 different small websites, but you don’t want to pay $1,200 a month for 40 extra-small web roles (2 per site to ensure availability)?

If that describes what you’d like to do, take a look at the Windows Azure Acclerator for Web Roles (WAAWR). It makes it easy to set up a single Azure web role that can host multiple IIS sites on it - 20, if you want, or more. You can set up 2 extra small instances of the accelerator role and only be out $60 a month for the instances. The initial deployment of the Accelerator takes several minutes, as is typical for Azure web role deployments, but deployment of each individual application is done even quicker and using the publishing tools built into Visual Studio. To see a demo of the WAAWR, watch Cloud Cover Show episode 51.

It’s a great tool, go check it out - I won’t rehash what’s already out there about it. Instead, I’m going to focus specifically on how to use Node.js with the WAAWR.

Node.Js
A short while ago, Ryan Cromwell, a coworker of mine, asked if Node could be run with the WAAWR. It seemed like it should, as WAAWR was just setting up IIS sites in Azure automatically, and Node could run in IIS alongside .Net apps, but I wanted to try it out for myself to be sure - and it worked without any problems. The following are the steps to take to get Node working with the Windows Azure Accelerator for Web Roles.

Read More

LinkPointTransaction.Dll

If anyone else out there ever has work with the LinkPointTransaction.dll assembly, I pity you. It is not an enjoyable experience.

I’ve been working on updating an eCommerce site, and before I started working with the payment code, I wanted to run a simple test transaction against LinkPoint so that I could gain familiarity with it before I started changing code around. Hopefully my story will help others in their struggle.

I first had to sign up for a developer account. That was fairly simple, and shortly thereafter I received three emails with 3 different accounts - apparently they have 3 different ways you can issue transactions.

1. Web Service API. This is a SOAP endpoint.
2. Virtual Terminal. This is where you log into their website and type in transactions manually
3. Connect. This is where you use LinkPointTransaction.dll to connect to their services

 

Once I figured out what the 3 different options were, I figured out that the app I was working on used #3. (Side Note: If you’re starting from scratch, I would recommend checking out the SOAP endpoint so that you don’t have to work with assemblies, COM objects, and custom SSL libraries that are several years old). I then went looking for documentation. I found the documentation site, but it took me a little while to figure out which PDF was the right one. I finally figured out that the API user manual was the right one. I had initially thought that the API user manual would have been the manual for the Web Service API, but I was wrong - the API user manual is for the Connect option.

Read More

Code Coverage and Web Tests

Download sample code for this blog entry here.

Solution Tree

Code Coverage can be a helpful metric to see how much of your code is hit by the tests you have written. Although it isn’t a way to measure how good your code is, it will at least help you to see what parts of your code have no automated tests written against them.



However, you can run into some difficulties when trying to do code coverage for tests that hit a web site. Let’s look at an example. Suppose you are creating a web application, and you want to write tests against it. Some of the tests will be unit tests that test out specific classes in isolation. Other tests will be integration tests that use HTTP to test the website. You can see the sample solution structure at the right.


First, we’re going to test the SampleLogic class in the Logic project. Here is the SampleLogic class:


public class SampleLogic
{
public int val;
public SampleLogic(int value)
{ this.val = value; }
public int Double()
{ return val * 2; }
}