Posted by John Lockwood on July 29th, 2006
Well, it’s Saturday morning, and what better time to extend one’s programming skills. Get 2/3 of a night’s sleep on Friday night, and wake up before the sun to write some Transact SQL for the realcrm project I’m working on, and along the way go install and start using Subversion for Windows.
Now that was just a pleasure. Install the thing, restart 4NT, read for 10 to 20 minutes, and hey, I’m checking things out and committing and gosh knows what. The only thing remotely like a hickup was the error message that I needed to set $SVN_EDITOR, so I added that to my 4NT startup batch file and away I went. Just what I wanted, version control for use on my personal products that runs fine from the command line and costs what I wanted to pay for version control for my personal projects, i.e., nothing. Of course, if you must use a GUI instead of a command prompt, and if talk of 4NT has you scratching your head, then check out Tortoise SVN, which integrates SVN into Windows Exploder. But don’t ask me whether that part works or not.
[C:\] Real men use the command prompt.
</geek>
A bit later, I’m going to go into my realcrm project and Frozzle the Sub Space Winch. I’ve been thinking that it needed a good Frozzling — just been waiting to have a 32-bit left handed frozzler to do it.
Maybe I should have gone for 3/3 of a night’s sleep.
Posted in Random Particles, Software | Add a comment »
Posted by John Lockwood on July 14th, 2006
I was just doing a bit of SQL Server hacking this evening to brush up my skills in that area, and I happened across this outstanding SQL Server Site that I thought I’d mention.
Suddenly I’m jonesing for yet another web site host, where I can play around with some .NET and SQL server application development. Meantime, the real estate sites are split between two separate hosts already, so I’m a bit hesitant in that regard, but at least one of the SQL Team authors gave Orcs Web a fairly glowing writeup.
Posted in Software | Add a comment »
Posted by John Lockwood on July 9th, 2006
I’ve uploaded the latest Sample Code for Exam 70-536. This batch includes the ICollection etc. samples posted last time as well as a few halting forays into ConfigurationManager — there’s more to do in that section, to be sure.
I’m not very happy with how the code formatting is going given the layout of the Particlewave site. I just don’t have enough room between the navigation and the right hand links to get a decent line of code in, it seems. We’ll have to look into that further, or give up the idea of blogging about code — I don’t like the latter alternative at all.
Posted in Software | Add a comment »
Posted by John Lockwood on July 8th, 2006
Here are the latest 70-536 exam samples. I’ll roll them back into the downloadable version soon.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using NUnit.Framework.Tests;
using System.Threading;
namespace ExamSamples.Bullet1
{
[TestFixture]
public class NewBullet1Tests
{
[Test]
public void TestICollection()
{
ArrayList al = new ArrayList();
al.Add("Something");
al.Add("Something Else");
// ArrayList implements ICollection
ICollection col = al as ICollection;
Assert.IsNotNull(col);
// Iterate in thread safe way using
// IColleciton.SyncRoot
// -- just an example in our case
try
{
Monitor.Enter(col.SyncRoot);
foreach (String item in al)
Assert.AreNotEqual(item, String.Empty);
// This failed. ArrayList is not thread safe
// Assert.IsTrue(col.IsSynchronized);
}
finally
{
Monitor.Exit(col.SyncRoot);
}
Assert.AreEqual(col.Count, 2);
Assert.IsFalse(col.IsSynchronized);
}
[Test]
public void TestIComparer()
{
ArrayList al = new ArrayList();
al.Add("Something");
al.Add("Something Else");
// No, IComparer is used on objects in collections,
// not collections
IComparer ic = al as IComparer;
Assert.IsNull(ic);
IComparable icomparable = al as IComparable;
Assert.IsNull(icomparable);
// Sort some fish (see fish implementation below)
SortedList sl = new SortedList();
// Insert in nonsorted order
sl.Add(new Fish("Fancy Goldfish",
Fish.Finsize.medium), null);
sl.Add(new Fish("Angelfish",
Fish.Finsize.large), null);
sl.Add(new Fish("Glassfish",
Fish.Finsize.small), null);
// Keys are now in sorted order
Fish f = (Fish)sl.GetKey(0);
Assert.IsTrue(f.FinSize == Fish.Finsize.small);
f = (Fish)sl.GetKey(2);
Assert.IsTrue(f.FinSize == Fish.Finsize.large);
}
[Test]
public void TestIEqualityComparer()
{
Cookie c1 = new Cookie();
Cookie c2 = new Cookie();
Cookie c3 = new Cookie();
c1.Name = "Keebler";
c1.HasChips = true;
c2.Name = "Swanson";
c2.HasChips = true;
c3.Name = "Keebler";
c3.HasChips = false;
// We've overriden Object.Equals as well,
// so this succceeds
Assert.AreEqual(c1, c3);
// Here's the IEqualityComparer version
Assert.IsTrue(c1.Equals(c1, c3));
}
}
public class Fish : IComparer, IComparable
{
public enum Finsize { small, medium, large };
private String _name;
private Finsize _finsize;
public Finsize FinSize
{
get
{
return _finsize;
}
}
public Fish(String name, Finsize size)
{
_name = name;
_finsize = size;
}
#region IComparer Members
public int Compare(object x, object y)
{
if (x == null ||
((Fish)x)._finsize < ((Fish)y)._finsize)
return -1;
if (y == null ||
((Fish)y)._finsize < ((Fish)x)._finsize)
return 1;
return 0;
}
#endregion
#region IComparable Members
public int CompareTo(object obj)
{
// This sorts in ascending order
// -- small fins first in our case.
return Compare(this, obj);
}
#endregion
}
public class Cookie : IEqualityComparer
{
private String _name;
private Boolean _hasChocolateChips;
public String Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public Boolean HasChips
{
get
{
return _hasChocolateChips;
}
set
{
_hasChocolateChips = value;
}
}
// Needed for our test to pass. Probably not for a
// hashtable.
// Object.Equals here
public override bool Equals(object obj)
{
return Equals(this, obj);
}
// also therefore need to override Object.GetHashCode
public override int GetHashCode()
{
return GetHashCode(this);
}
#region IEqualityComparer Members
public new bool Equals(Object x, Object y)
{
Cookie cx = x as Cookie;
Cookie cy = y as Cookie;
return (GetHashCode(cx) == cy.GetHashCode(cy));
}
public int GetHashCode(object obj)
{
Cookie c = obj as Cookie;
// Easy -- defer to one of our strings
// to hash by name of cookie.
return (c.Name.GetHashCode());
}
#endregion
}
}
|
Posted in Software | Add a comment »
Posted by John Lockwood on July 8th, 2006
I’ve posted my 70-536 Exam Sample Code that I mentioned last time. We’ll have a few tests from this NUnit test suite posted here on the blog shortly too to give you an idea.
Posted in Software | Add a comment »
Posted by John Lockwood on July 1st, 2006
When it’s a classroom!
OK, I admit it, I’m being obtuse. As programmers sometimes say to being caught in the act of being obtuse, “Why Do You Think They Call It ‘Code’?”
I’ve written about JUnit unit tests in the past, and and one could say that I was able to parlay my current contract based on my experiences with test first design, since the client in this case was interested in someone experienced with Xtreme Programming, and test first design and development is one of XPs cornerstone processes.
And indeed, at work it wasn’t long before we had an NUnit test suite going — I’ve been plugging my way through our new database test suite for a few days now. The coolest thing (in my opinion) to happen to unit testing in the time since I first used JUnit is automatic test composition. Back in the JUnit days, you had to create (and — worse — you had to maintain) a TestSuite. In NUnit, there’s no such restriction, simply mark the test classes and methods you want with the appropriate [TestFixture] and [Test] attributes, respectively, and you’re off and running. We’re using Namespaces to organize our tests in a visually appealing and logical way.
Today when I got Visual Studio installed, it also occured to me that NUnit is an ideal “snippet viewer” sort of an application, the kind of thing that’s ideal for organizing and writing code to learn new things and excercise unfamiliar classes — which of course is just the sort of thing if you’re preparing for a certification exam. So a test (in the software sense) is not a test when it’s a classroom to help you prepare for a test (in the academic sense).
It’s all good.
So I’m going to work in that way for awhile, developing my sample “apps” (i.e., learning exercises) in NUnit, and perhaps I’ll publish them up here for what it’s worth.
Posted in Software | Add a comment »