in

But it works on my PC!

The random thoughts of Richard Fennell on technology and software development
  • Like the new Blog theme?

    Lauren has has restyled our blog server to match the new company web site and also done a matching blog template.

    Do you like it?

  • XP Club meeting

    An excellent turnout for tonights XP Club meeting. As I write Nick McKenna is talking about his experiences in adopting agile processes.

  • Flash problems

    Are you seeing the error "Cannot play media. You do not have the correct version of the flash player. Download the correct version" on the BBC web site or on YouTube  "Hello, you either have JavaScript turned off or an old version of Macromedia's Flash Player. Get the latest Flash player"?

    I have been on my Dell Mini; I suspect the problem was the upgrade route I took from XP-Home -> IE8 Beta ->XP Prof meant the registry was a mess. Repeated re-installation of Flash and Shockwave had no effect.

    After much fiddling I fixed it by downgrading to IE7, running the Abode Uninstaller, the installing Flash and upgrading to IE8 again. However I suspect I did not need the IE downgrade first, but I had done this previously.

    Hope this saves you some time.

  • Running fitness.Net tests in unit test – some tips

    I posted a while ago on wiring in Fitness.Net into a unit test framework using HTML files to hold the tests. Well I have been using the technique for some workflow acceptance testing and hit a couple of gotta’s that are easy to forget:

    • Make sure the HTML files containing the user story tests are set to copy to the project output directory in the IDE – if they are not then the framework cannot find the tests, so obviously none are run. The danger is you think the problem is an incorrect class or method name, when it is a simple missing file problem.
    • If you edit the user story HTML file make sure you rebuild the solution. If you don’t do this the copy to the output directory might not be triggered as a simple build maybe skipped as the IDE will not see any changes to source files it needs to compile the project. This is especially easy to forget if you are using a test add-in such as Testdriven.net as opposed to clicking on build yourself.
    • Be careful with the HTML editor you use to create user story file in case it reformats the page. This is important for parameters (but it seems not for the method name fields). You need to make they are formatted

               <td>My Value</td>

    as opposed to

               <td>
               My Value
               </td>

    as the latter will include the carriage returns characters in the parameters passed into the test so will probably fail.

    I think that is all for now, I will post any others I find as they crop up

    Posted Oct 04 2008, 10:39 PM by Richard with no comments
    Filed under:
  • Upcoming events in October

    It is getting to that conference time of year again; I can’t believe the PDC is only 3 weeks away, then VBug  the next week and DDD7 just after that.

    A bit closer to home there are some free events coming up this month:

    Look forward to seeing you at one of the events in Yorkshire

    A bit further from home, Guy has had a bit of a coup at the Bristol .Net Usergroup. He has got Oren Eini the developer of RhinoMocks speaking on the 13th of October during a rare UK visit. For those of you who the name Oren is not familiar, he is the man behind blog http://ayende.com/blog/ a major resource for all things Agile.

  • The October Power Tools Release

    I posted about the problems of using Blend with source control, specifically TFS. Well the next version of TFS Power tools gives a partial answer.

    They are to include Windows Shell Extensions so at least the check-in/out process can be managed would having another application open other than an explorer windows.

    Well it is step forward, until Blend 3 appears

    Posted Oct 03 2008, 07:44 PM by Richard with 1 comment(s)
    Filed under:
  • Testing Driven Development for Workflow Foundation

    As we move into the SOA world workflows will become more common and so the need to test them will increase. If we take the most simplistic view these are a sets if statements and loops so should be amenable to automated testing and TDD.

    However you have to careful how you try to do this, it is too easy to forget that your workflow will run the the WF thread. Why is this problem?

    Consider this scenario, if you create a simple sequential WF console application you get a block of code like this in the Main(args) method

    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
       AutoResetEvent waitHandle = new AutoResetEvent(false);
       workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
       {
          // could put asserts here (A)
          waitHandle.Set();
       };

       workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
       {
              // could put asserts here (B)
       
       waitHandle.Set();
       };

      WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1));
       instance.Start();

       waitHandle.WaitOne();
    }

    // could put asserts here (C)

    This block of code will be the basis of each of your unit tests, but as indicated you could put your test asserts at one of three places

    • In the success delegate
    • In the fail/terminate delegate
    • After the workflow has completed

    The best place is the third option, when the workflow has finished, even though you know in a test whether it should completed OK or failed. The problem with the previous two locations is that the anonymous delegate will be run in the WF worker thread. Interestingly, if the assert passes in this location all will be OK, but if it fails the thrown assert exception (the mechanism used in nUnit to trap failure and in other test frameworks to my knowledge) will be in the wrong thread and so will not be picked up by the test harness, so in effect the test runner stalls waiting for completion or an exception, neither of which arrive. This issue is not the the case if the asserts are done when the workflow completes. This does mean that you have to pass results out of the workflow, but this should not be a major issue as the results should be simple objects (workflow parameters) or checks on external (mock?) systems, such as file systems, DBs or Smtp servers.

    Though not always standard practice in TDD, I think it is a good idea here to move the code in the above sample’s using statement into a static method in your test class; it is boiler plate that will probably be use in many tests. As tests are meant to readable I think a single line call to the RunWorkFlow() method is better than a block of repeated loop and delegate code. Remember you do have to be careful here, as you may need to pass in parameters and get a return value to get the end state of the workflow; the requirement will depend what your workflow does and how it interacts with other systems. It maybe you need more than one version of the RunWorkFlow() static method depending on what is under test e.g one to harvest output parameters from completed workflow runs and another to harvest inner exceptions that are inside the workflow terminated delegate.

    So now there is not reason to not test your WF workflows – assuming you can mock out any external connections, and if you are using web services or IoC to talk to data stores this should be fairly easy. 

    Next I am off to try to do the same with SharePoint workflows.

    Posted Oct 03 2008, 07:28 PM by Richard with no comments
    Filed under: ,
  • XP Home to XP Professional when IE8 is involved

    The one major thing that I did not like with my Dell Mini was the fact it had installed XP Home. My main grip with this was the fact my main user account had to be an admin user, and I could not login as a user called administrator unless in safe mode. So I decided to do an in place upgrade to XP Professional (which also meant i could join the company domain). This seemed straight forward, I attached an external USB DVD and got the XP Professional SP3 slipstream media. The process continued as you would expect until the final reboot where it sat on the splash screen saying 'please wait' for a hour or two.

    Normally you would have a disk activity light to give you confidence something was happening (oh that the other thing I miss on the Dell Mini). Anyway after a couple of hours I decided nothing was happening so did a hard reboot and up came the PC upgraded. I could login as administrator (in normal mode as opposed to just in safe mode) and set file encryption - so all seemed OK.

    However I then tried to access the Internet. Initially this seemed to work, but as soon as tried to follow a link on a page I got a message about 'no activation context in the registry'. Also when I tried to activate the new Windows license I got no dialog, it seemed the MSOOBE.EXE that is run behind the scenes was failing. It became obvious I had a corrupt IE install; the in place upgrade had left me with an interesting mix of IE 6, 7 and 8 beta. This is why I think it stalled on the splash screen.

    So I downloaded the IE8 beta again, reinstalled it and everything started to work.

    So the technical tip is - if you are doing an in place Windows upgraded remember that you are probably going to alter the version of IE and as it is intrinsic to how Windows operates you might get problems. Make sure you get the known version you want at hand to reinstall it.

  • Further thoughts on mocking out a SMTP Server

    I posted on the problems I had had mocking out an SMTP server, well I have moved on a bit. As I said in the update note in the last post, I had given up on nDumbster and moved over to LumiSoft's freeware mail server.

    The Lumisoft server is a far better starting point as it is a 'real' server that supports all the major mail protocols. As all the source (and binaries if you can't be bothered to build it yourself) are shipped it is easy to create a wrapper class for unit testing purposes that can do whatever you need.

    However even with this much improved server I still had a problem with System.Net.Mail calls. I had four tests

    • Send a single email with System.Web.Mail
    • Send a single email with System.Net.Mail
    • Send a batch of three emails with System.Web.Mail
    • Send a batch of three emails with System.Net.Mail

    Before each test a new SMTP server was created, and when the test completed it was disposed of. Each test worked if run by itself.

    The problem was that if the tests were run as a batch the final test failed. When the SMTP server was checked it was found to have no messages recorded, not the expected three. However, the logging said three messages had been sent OK. Swapping the order if the tests did not effect the basic issue that the second System.Net.Mail test reported no emails received, whilst the System.Web.Mail tests were fine.

    By adding a unique identifier to each created SMTP server it could be seen that the fourth test was sending its mail to the second SMTP server (which should have been disposed of well before the fourth test was started) hence the final test failing.

    The problem appears to be that the threading model inside System.Net.Mail holds the TcpClient object in memory for longer than you would expect, so somehow allows the fourth test to reuse the connection (and server) from the second test. Though it is unclear how you are able to have two servers both on port 25 at the same time. I guess this theory could also go some way to explaining the issues I had with the nDumbster implementation.

    Though not perfect, the solution I used was to make the Smtp Server instance static for the test class so for all the tests I created just one instance of the server. Before each test I cleared down the received messages store. Thus far this is working reliably for both single tests and batches of tests.

    Update 6 Oct 2008 - The use of a static Smtp server per class is not a full solution, but just moves the problem on i.e. you get the same problem is you have two classe in the batch each with their own server. I need to find a better way to rip the Smtp server of memory - Maybe an AppDomain?

    Update 10 Oct 2008 - Well AppDomains don't help. The best solution I have found is to not use a static Smtp server but to instaniate a non static member one and then start it in the test systems TestInit method. In the test systems TestCleardown I stop the server and dispose of it. However this does not fix the problem. I therefore then send an email to the server I have just disposed using System.Net,Mail. This obviously fails but does cleardown the internal cached items inside the System.Net.Mail structure. I just catch the expected exception and carry on. I know it is not elegent but it works both within a test class and an assembly containing many classes 

  • 'Datadude' merged with Team Developer

    It was announced overnight by Microsoft that the Database Professional SKU for Visual Studio will be made available to all people who have a licensed copy of Team Developer.

    This is great news as it addresses the problem of where to put the expensive copy of DataDude (which I think has been a barrier to it's uptake), in most companies there is not the clear distinction between code and DB devs.

    So as of tomorrow you can get DataDude via MSDN. You can read more about the recent announcements here: http://msdn.microsoft.com/en-us/vstudio/products/cc948977.aspx

    Posted Sep 30 2008, 01:45 PM by Richard with no comments
    Filed under: ,
  • Mocking out an email server

    I am currently looking at automation of acceptance testing for workflows and a common task is to make sure an email has been sent. To do this in a TDD style I have been using the mock SMTP server nDumbster.

    Now this was a port from Java in the the days of .NET 1.1 and does not seem to have had any development since. This can be seen because the following test using the .Net 1.1 System.Web.Mail call works beautifully, returning in a second or so

    [TestMethod]
    public void CanRecieveSingleWebMail()
    {
    System.Web.Mail.SmtpMail.SmtpServer = "localhost";
    System.Web.Mail.SmtpMail.Send("somebody@foo.com", "everybody@bar.com", "This is the subject", "This is the body.");
    Assert.AreEqual(1, smtpServer.ReceivedEmail.Length);
    }

    However the test using the .Net 2.0 System.Net.Mail is not so good

    [TestMethod]
    public void CanRecieveSingleNetMail()
    {
    System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("localhost");
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("somebody@foo.com", "everybody@bar.com", "This is the subject", "This is the body.");
    client.Send(msg);
    Assert.AreEqual(1, smtpServer.ReceivedEmail.Length);
    }

    It does work but takes 100 seconds to return, a bit of a pain for TDD!

    After a bit of debugging I found the problem was the final input.ReadLine(); in HandleSmtpTranslation which we expect to get a null at the end of a message, for Systsem.Web.Mail this returns instantly, but for System.Net.Mail this takes 100 second, but then is fine.

    As a work round I have put in the logic

    string line = null;
    if (smtpState != SmtpState.QUIT)
    {
        line = input.ReadLine();
    }
    if (line == null)
    {
        break;
    }

    This works fine for single mail messages, using both the old and new API.

    There is still a problem, with the System.Web.Mail API you can send multiple emails in a test, but this still fails for System.Net.Mail – the first goes OK, but the second fails saying the server is not present.

    By the way I have ruled anti virus and anything specific to port 25 causing the problem. I suspect a threading issue as I believe System.Web.Mail was single threaded wrapper for COM and System.Net.Mail is multi threaded pure .Net logic.

    If I get a better solution I will post about it, but I have enough functionality for me at present.

    Update 28th Sep – Got an email today via the SourceForge forum that pointed me at the freeware LumiSoft mail server. On a first look this certainly appears to do the job. You just need to wire it into your tests in a wrapper class of your own.

  • First thoughts on the Dell Mini 9

    After Alt.net I had thought getting an ultra light notebook was a good idea. At most conference I need to browser, blog and read email; I don’t need to carry around a full development desktop replacement laptop.

    Whilst at ReMix I had enough of the old battery in my Acer laptop, so just before it ran out of juice again I ordered a Dell Mini 9, which was actually cheaper than my HTC phone! Today it arrived, a lot sooner than I was expecting, Dell has said it would be next month.

    Inspiron Mini 9

    My first thoughts? Well the keyboard is small, typing is an interesting experience as I type this post. Also I would like a disk activity light; during the XP setup there a good period when I was not sure what was going on, a flickering led is always reassuring.

    Other than these minor gripes it seem very good, it is light, the battery life seem as advertised and it is fast enough for Office 2007 (so I can use it for presentations) and messing around development (I popped on C#  Express but there is disk space left for VS2008 if I needed it).

    I will report further when I have lived with it a while.

    Posted Sep 24 2008, 07:45 PM by Richard with 1 comment(s)
    Filed under:
  • So what will we need to run 'Rosario'?

    Brian Harry has published an interesting post on the platform decisions for 'Rosario'.

    The most interesting item is it will only support SQL 2008; so get planning a migration for that central enterprise SQL server!

    Posted Sep 23 2008, 09:10 PM by Richard with no comments
    Filed under:
  • Post ReMix thoughts

    So how was ReMix? well a bit like last year not earth shattering, but what can you expect. We have PDC in a month so there is going to be no major announcements, also this is a rerun event from the US MIX conference, again reducing the chances of anything new.

    So if you are a developer and been to TechEd or just to local community events (and as Andy Westgarth said we are very lucky at the quality and number of community events and speakers in the UK) you will have heard nothing new about Silverlight etal. Though it is far to say that this may not be true for designers, and I felt the development track was pitched at this level.

    It is with design where I think ReMix was different this year; there were noticeably more designers present and I thought the design track a lot stronger. As I had seen most of the developer track elsewhere I spent a good while in designer sessions, and as usual when going beyond your normal bounds it makes you think.

    What has been bubbling in my mind is how does the design process fit into agile processes? Bill Buxton in his sessions (and new book) spoke about how it was important for the designer to provide a variety of concepts for the client/project and not invest all their effort in a single design, thus removing choice form the 'client' . It got me think should the same apply to the developers/architect? Is this even possible? At the grossest sense it would mean developers would propose (prototype?) versions of a product in PHP, Java, Flash ASP.NET, Silverlight etc. Now we all know this does not happen, early in a project a hopefully informed choice will made as to the technology to use (often this choice is made in the choice of who gets the business - a PHP house or a Microsoft house), and it is rare a change will be made in base technology once the choice is made. Even though a project is agile there are limits as to how major a change of direction could be,

    So is this a difference between design and development, in web design we can ask the client how it should look, you still need to provide quality design with sane user interactions, but the client can have some choice e.g. 'I like  a more cartoon style', 'I want just like that but in red'. You are not going to get the same interaction from the bulk of clients for development and architecture, it is rare you hear 'Just like that but can you use SOAP'. Development constrains tend to be just that, things that must be done to meet a standard, not something open to choice at the non specialist level.

    So ReMix was an interesting event, and good to see many friend from the community. And if it opened my mind to something new it must have been worth attending.

  • Rebuild of GUITester

    I have eventually got round to rebuilding my GUITester on Codeplex for VS2008. I must get round to looking to see if a similar declarative test markup system has any mileage for XAML. Something was talking about at Alt.net in the spring - how time flies.

More Posts Next page »
Black Marble 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems