Ivan Krivyakov's Blog

Premature optimization is the root of all evil

July 6, 2010

VS 2008 unit test host cannot run tests in one thread

Our UI code is single threaded and UI classes use some shared static data. They work just fine, but the unit tests sometimes fail. Investigation led to threading issues. Visual Studio unconditionally runs tests in multiple threads simultaneously, and apparently there is no way to tell it not to do that.

http://social.msdn.microsoft.com/Forums/en-US/vstswebtest/thread/4cdd4668-d99c-4699-8e1c-b775498593e7

July 1, 2010

WPF: Is clone of Freezable frozen?

WPF defines a Freezable type that is a base class for “almost immutable” objects. They can be setup in read/write mode and then “frozen” which makes them immutable and thread safe.

Freezables are also cloneable. If I make a clone of a Freezable, will it be frozen? Fortunately, it won’t, so I can modify the clone at will, and then freeze it if necessary. Here’s the passing unit test that proves that:


   [TestMethod]
   public void ClonedFreezableIsNotFrozen()
   {
      var brush = new SolidColorBrush(Colors.Red);
      brush.Freeze();
      var clone = brush.Clone();
      Assert.IsFalse(clone.IsFrozen);
   }