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

Debugging T4 Templates

NB: This post is relevant to Visual Studio 2010

T4 templates are a great way to write code that writes code. Huh? I’m not going to go into it here, so if you want more information, see Scott Hanselman’s post on T4 templates, as well as Oleg Synch’s posts.

One of the pain points when writing T4 templates is with debugging them. Sometimes you’ll save a .tt file and get some obscure error message that is impossible to figure out, and you have no clue what part of your T4 file is messed up.

It is possible to debug them, and Oleg provides some great pointers. Here is my summary of how to get it working:

Read More

Constructor vs. ClassInitialize

I recently ran across some code in a test class where I saw that the class was initialized in a constructor rather than in a method with the ClassInitialize method, and it made me wonder - what’s the difference?

The goal is that we have a test class with several test methods, and we have some initialization code that is common to all of the test methods. We want the initialization code to run only once for the entire set of tests, not once per test.

One way to do this is to put the initialization code in the constructor, like this:

1
2
3
4
5
public MyTestClass()
{
var x = 5;
x.Should().Be(4); // Fluent Assertions
}

Another way is to create a static method with the ClassInitialize attribute, like this:

1
2
3
4
5
6
[ClassInitialize]
public static void Init(TestContext testContext)
{
var x = 5;
x.Should().Be(4); // Fluent Assertions
}

So what’s the difference?

Read More

Sendoid

2012-06-15 Update: Sendoid.com has shut down.

2015-04-16 Update: For an alternative, try Bittorrent Sync.

I’ve been keeping an eye out for a simple way to share a large file (1-5 GB) to another person over the internet privately, and I finally found something that I like. Sendoid.

The uploader and downloader can use it either from the web page or from the client app they provide. However, if you use the client app you get the ability to resume a transfer in the event that it’s interrupted, which is very important for large files.


You can have multiple people downloading from you at the same time, and when you’re done, remove the file from the list or close the app. Very simple, no registration or signup required.

Thanks, Sendoid!

http://sendoid.com