2011-09-27

Mailinator.com

If you ever need to test a system with lots of different unique email addresses, then Mailinator may be just the thing you need.

Whenever you send an email to some random name @mailinator.com, you can go into the mailinator web site, type the email address (without the “@mailinator.com” part), and log on to check the mail. You don’t even need to register.

Some scenarios may be:

  • Register users with unique emails
  • Test confirmation mail functionality
  • Test forgotten password functionality

2011-09-15

Adding a ToXmlString() extension method to all objects so that they may be viewed as Xml when debugging

Working with soap Request and Response objects I have found that it is a nice thing to be able to check the request, and copy it into SoapUI to test what really is going on. So my first thought was to create an extension method and put it on all my request objects, but it takes some work, so I went for the lazy solution: add extension method on System.Object. Now this may not work on all objects, I think they need to be serializable at least, but it seems to work on my request objects. So here’s my code, just use it with caution, as it may have side effects:

using System;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Xml;

public static class ExtensionMethods
{
    public static string ToXmlString(this System.Object obj) { return serializeObject(obj); }
   
    private static string serializeObject(object obj)
    {
        XmlSerializer xs = new XmlSerializer(obj.GetType());
        StringWriter sw = new StringWriter();
        XmlTextWriter w = new XmlTextWriter(sw);
        w.Formatting = Formatting.Indented;
        w.Indentation = 3;

        xs.Serialize(w, obj);
        w.Flush();
        w.Close();

        return sw.ToString();
    }
}

 

2011-09-07

Compare Stored Procedures in 2 SQL Server databases

Using the following script it is possible to get an idea if the stored procedures in two databases are equal.

SELECT A.ROUTINE_NAME, A.ROUTINE_DEFINITION, B.ROUTINE_DEFINITION
FROM sourcedatabase.INFORMATION_SCHEMA.ROUTINES A
LEFT JOIN targetdatabase.INFORMATION_SCHEMA.ROUTINES B ON A.SPECIFIC_NAME = B.SPECIFIC_NAME
WHERE RTRIM(LTRIM(SUBSTRING(A.ROUTINE_DEFINITION,CHARINDEX('CREATE',A.ROUTINE_DEFINITION),999))) <> RTRIM(LTRIM((SUBSTRING(B.ROUTINE_DEFINITION,CHARINDEX('CREATE',B.ROUTINE_DEFINITION,0),999))))
ORDER BY ROUTINE_NAME

Even if the routines have the same functionality, they may have some slight differences, like spaces in front of the CREATE PROCEDURE statement and also trailing spaces at the bottom. I have tried to remedy this by trimming and also comparing substrings where initial spaces have been removed. Still room for more improvement, I’m sure, but just a small idea.