Wednesday, January 13, 2010

Regular Expressions with PowerShell

I came into Regular Expressions using Perl, and I must say I liked it and enjoyed it immensely once I was able to actually figure out how to do the syntax, never mind doing captures in order to use specific values from strings later. Although, like most things, once you do it then its simple and you think, "that was not so bad" when you look at something that looks like you kid typed when you left the computer on.

Perl was one thing, PowerShell is another. Now that I have this figured out its simpler, but finding the information on it was not so simple, although I will say one thing that made it easier was having a Designer tool that went over some of it. The Rad Software Designer is a very good tool for being able to help figure out the syntax as well as give you a place to assure that the results will be what you want, and since PowerShell is based off the .Net Regular Expression implementation the result will work fine there.

My goal was to be able to match a line like this:
Assertions: 8 right, 0 wrong, 0 ignored, 0 exceptions
So I could get the numerical values for display, turns out I only needed this:
:\s(?\d+)\sr.*(?\d+)\sw.*(?\d+)\si.*(?\d+)\se.*
...and then I could use some named capture values to then display the information I need. Now if I could only figure out how to turn off the True statement being displayed, that would be great.

Wednesday, January 6, 2010

More SharePoint News!

I am doing some of the Microsoft Hand On Labs (HOL's) for SharePoint 2010, normally I would post a link to these but they are so amazingly buggy with typos and code that doesn't compile (or write without errors appearing) that I would rather let anyone really wanting them to seek them out. I downloaded them from Microsoft somewhere, they are from early 2009 and it looks like someone wrote them up quick and then somehow got them on the Microsoft site; I can't get past two pages without a typo and I hate that. The code has errors, I know enough to fix some of the warnings that show up in Visual Studio 2010 when I write out the C# examples, so I would not push this on anyone.

Still, because of this I have had to go out and research errors now and again, what I have found are a couple of interesting posts on sites:
So far I am having middling luck in scripting many of the Web Parts I have been able to compile with Fitnesse, I have also found that I right now need to deploy and add Web Parts on the same environment. I cannot deploy through Visual Studio 2010 on one machine then add that Web Part on another machine, I kept getting errors regarding that the object did not exist even though it appeared in the Web Parts list. So, I am running things locally until I know they are on the site and working, then I go to another machine and script with Fitnesse.

Fitnesse also doesn't seem to like the naming conventions that SharePoint gives for certain objects, I am trying to find a solution for that as select lists may have their own ID's and Name's with the SharePoint strings in the future - so I am working that out now.

Enjoy!


Note: I've edited this page to now note the Labs, they are for 2010 and I figure why not share the fun.

Monday, January 4, 2010

SharePoint and Fitnesse - a match made somewhere...

Now that my current web redesign project is going to be based on SharePoint 2010, yes its in Beta and we know this but we are still going forward with this anyway...not my decision but it should be interesting, I have migrated some of the old Fitnesse scripts I had to the new platform. In addition, I have upgraded from using the Fitnium add-on to FitLibrary and the SpiderFixture since it gives better Internet Explorer integration than Fitnium did, while FireFox will still be tested it won't be the focus that it was in the past.

So far I have encountered some issues with the way Fitnesse sees the pages, since SharePoint's web parts can act like Ajax some adjustments need to be made, also SharePoint masks some of the standard ID's of the base pages with its own ID scheme. Some of those ID's are not only odd, but sometimes they are very long, in addition SharePoint's ability to be made of many dynamic pieces makes validating some pages very tedious.

In the past I did make Fitnesse a service on my machine, that way I always had it up and running, however, in recent releases I have had trouble with the connections from the browser to the site under test. Today I noticed something odd, when I was running a new install on the command line everything worked, running the same script on the Fitnesse server that ran as a service there would be failures. On the command line the browser would open a new instance and run its tests, on the service version nothing would show up. So I did a check and sure enough I did a nice default, when I set up the service I set it to run as Local System, but when I run command line I run as myself. Changing the Log On to myself, and granting myself access rights, I can now get the same scripts to pass on the new install.

I'm now running FitLibrary 20091021 release with Fitnesse 20100103, so far basic stuff looks fine and good, I just hope I can keep this running.