Monday, May 18, 2009

nunit and VS2008

I’ve recently started using NUnit on some of my side projects, and the one frustrating thing has been the lack of ability to debug the unit tests. 

I know, I can see the “run” external app on the unit test project to point to the nunit directory, or I can run nunit, manually attach to process, etc.  But those seem kinda hacky.  Or I could shell out money for other solutions.

Well, codeplex has once again saved the day:

 

NUnitit is a project that adds a new tools menu that will allow you to debug VS projects in NUnit without having to set the execute remote, or attach process.  It in will auto detect the NUnit install, so if you have NUnit installed in a different directory, you’ll still be fine.  And you aren’t forced to always use NUnit.  You can set your projects up for MSTest and NUnit and be able to debug both.  I hope it’s

Friday, May 15, 2009

Top 1 in a subquery…

So I came across an interesting sql problem.  I have a list of devices that could have multiple customers attached to the device.  And on the admin page, i need to list the devices and at least one customer attached to the device.

I didn’t want to display multiple rows in the table each with the same device but multiple customers.  This is how I solved it:

select * 



from devices d left outer join customers c on d.id = c.deviceid 



        and c.id = (select top 1 id from customers where deviceid = d.id)




 



The first left outer join, insures that if i have a device with no customers, I’ll still get the device results back.  If I have multiple customers, I’ll get the first one returned.  I could put other “filtering/sorting” in the subquery if i wanted, but this seemed to work enough for my purposes.

Thursday, May 14, 2009

Bugged by FindControl….

 

I’ve always been bugged by the “FindControl” method on the Gridview, or any part of the page (I mainly use it on a gridviewrow after selecting).  So I wrote a little Generic method.  This can be added to a utilties class, or just on the codebehind page itself:

 

   1: public T FindControl<T>(Control searchControl, string controlId) where T : Control {



   2:         return (T)(searchControl.FindControl(controlId));        



   3:     }




To use the new FindControl:





   1: Label foo = FindControl<Label>(gvTest.SelectedRow, "myIDLabel");




This is instead of doing something like:





((gvTest.SelectedRow).FindControl("customerId") as Label).Text




Well, at least it seems cleaner to me in code.  I’m sure that there are better ways, but this works for me for now.

Tuesday, May 12, 2009

Amazing tool for VS 2008 and Sql Server

I was just told by a friend that I need to check out what he called “Data Dude”, which is an add-on for Visual Studio 2008. 

It adds a Database Schema compare so that you can compare two different databases.  I ran it on our beta db and dev db, and found several differences that I didn’t expect. 

Everything from triggers, indexes, columns, etc. 

dd1

It’ll let you drill down into the dependencies, allow you to make the updates, or create new items, etc:

dd2

You can easily see the differences:

dd3

Here’s the Link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&displaylang=en

Windows Live Writer

My first post from windows live writer.  This is suppose to make blogging easier.  So we’ll see. 

 

http://download.live.com/writer

 

Update:  Adding plug-ins are cool.  I’ve added a code snippet, and this is what it looks like for formatting:

   1: foreach(bar b in foo) {



   2:  b.SayHello();



   3: }






And this is what the Code Snippet window looks like:



image



You can copy and paste images from the clipboard (as I just did), and this makes blogging awesome. 



 



So 2 cool tools today!

Wednesday, April 22, 2009

How to Resize a VMWare Disk

I use VMWare, and one problem is that the default save being 16gb often runs out of space. After googling for an easy method for increasing the size, I've found several solutions involving using Linux boot CDs, tools etc. This is how I did it:

First, use the VMWare command*:

C:\Program Files (x86)\VMWare\VMWare Workstation\vmware-vdiskmanager -x 32Gb "x:\Dir\DiskFileName.vmdk"

Or where ever your VMWare workstation is installed
This will increase it to 32gb

Then go to http://www.partition-tool.com/personal.htm and you can use their free version to increase the primary drive.

the free version only supports 32bit OS, so if your vm is 64, you might look at mounting the linux iso at www.sysresccd.org to increase the partition.

Hope that helps.

* one thing to note, I read somewhere that you should not have any snapshots of the drive sitting out there. Also, back everything up first before trying (I made full clones, just in case).

Tuesday, September 2, 2008

A nifty program...

Here is a very nifty site for formatting code for HTML:
http://www.manoli.net/csharpformat/

what makes this really good, is that you can nest the css into the document, so for sites where you can't link the css, you can still use it.

I use the output of this for our internal wiki with sql.

Here is a screenshot of the output : (unfortunately, blogger is overriding the css)



So, hopefully someone can tellme how to override the css in blogger, so that it works. However, for the Sharepoint Wiki that we use, it's great.
And the source is available, so that you can fix some of those bugs, such as no space after a -- causes the comment to not be formatted.