ploeh blog

Mark Seemann's discontinued .NET blog.

Browse by Tags

Tagged Content List
  • Blog Post: Test-Driven Properties

    Zero-Friction TDD post #10: In principle, defining properties (or fields, for that matter) while TDD'ing should be no different than defining methods . Again, the important part is to stay focused on the test at hand, and not become bogged down by implementation details. Unfortunately, neither...
  • Blog Post: Use The Generate Method Stub Smart Tag To Stay In The Zone

    Yet Another Zero-Friction TDD Article (YAZFTA): When writing unit tests in the TDD fashion, it's important to stay in the zone and not get side-tracked by irrelevant issues. You need to avoid what I call mental context switching. Focus on writing the test and postpone all else to later, but make sure...
  • Blog Post: Assert Messages Are Not Optional

    ...and now, in this week's episode of Zero-Friction TDD : Optional Assert messages that aren't optional anyway! Actually, this piece of advice comes almost directly from the xUnit Test Patterns book, so I was in doubt whether I should post it all, but it bears repeating, and I guess I still have a...
  • Blog Post: Why Use AreEqual<T>?

    This is a post in my Zero-Friction TDD series. One of my colleagues recently asked my why I prefer Assert.AreEqual<T> over one of the non-generic Assert.AreEqual overloads for primitive types. In most cases, I'm very happy with the C# compiler's ability to infer generic type arguments from...
  • Blog Post: 3 Is Many

    This is an installment in my Zero-Friction TDD series. When I was a kid, my parents taught me that many is any number above three two*; they used the simple counting sequence one, two, many . This little story may make me seem like I was an incredibly dim-witted kid, but the point was obviously not...
  • Blog Post: testmethod Code Snippet

    This is an installment in my Zero-Friction TDD series. If you are a regular reader of this blog, you may have noticed a certain pattern in my unit test examples (like this one ). This is because I always follow the Four-Phase Test pattern (which is a superset of the more well-know Triple-A (Arrange...
  • Blog Post: Ignore Irrelevant Return Values

    This is an installment in my Zero-Friction TDD series. Sometimes, you don't care about the return value from a particular operation. The simplest example is if you want to check that creating a new instance of a specific type will throw an exception if supplied with wrong parameter values: [ ExpectedException...
  • Blog Post: Anonymous Variables

    This post is an installment in my series on Zero-Friction TDD . Often when writing a unit test, the SUT 's API will force you to create objects that you really don't care about. As an example, take a look at the signature of this constructor: public Plop( int number, string text) To create an...
  • Blog Post: Naming Direct Output Variables

    In my series of Zero-Friction TDD tips and tricks, it's time to look at naming Direct Output variables. [ TestMethod ] public void DoStuffWillReturnMessage() { // Fixture setup string expectedResult = "ploeh" ; MyClass sut = new MyClass (); // Exercise system string result = sut.DoStuff(expectedResult...
  • Blog Post: Zero-Friction TDD

    Writing good code is difficult. Unit tests are written as code, so a corollary to the first sentence is that writing good unit tests is also difficult. TDD (particularly if you interpret the last D as Design ) carries this challenge in abundance, since you ought to be focusing on designing your SUT...
  • Blog Post: Vote For Better TDD Support in Visual Studio 2008

    Eric Jorgensen has created a Microsoft Connect item asking for better TDD support in Visual Studio 2008 . If you also miss the green (sometimes red) progress bar and other UI elements of NUnit and similar tools, and think that Visual Studio should have a UI that supports TDD better than it currently...
  • Blog Post: Automatically Generating LINQ To SQL Models From T-SQL

    With LINQ to SQL, a couple of questions quickly arise: Since you can create a data model directly in Visual Studio, where's your authoritative definition of the database? If you generate a data model from your database, how do you maintain the model if you have to tweak it? The first question...
  • Blog Post: Visual Studio 2008 PowerShell

    Ever since I first saw a demo of PowerShell some five years ago, I've been wanting to use it for development work; such as automating code generation or whatever other task for which small scripts are needed. It's such a powerful environment, and I simply love the fact that it's based on .NET and that...
  • Blog Post: Race Troubleshooting Using The Console Output In VSTS

    It must be my week of discovering the obvious . The other day I was troubleshooting a race condition in my code. I had a unit test that faithfully reproduced the error, but just looking at the code involved didn't produce any sudden insights into its reasons. The nasty thing about race conditions (and...
  • Blog Post: Agile Proves Effective Once More

    Christian , one of my old (and present) collegues, has just posted about his team's latest accomplishment , shipping six months ahead of time! I'm sure that the team consists of a bunch of very talented people, but I'd also venture a guess that their adoption of agile methodologies has a lot to do with...
  • Blog Post: SQL Server On Vista Development Machines

    As an enterprise developer, I've always had SQL Server on my laptop (which is my main development machine), and it's been quite some time since I got my first laptop (1999). For years, SQL Server has been an indispensable tool for enterprise development, since the kind of application you tend to write...
  • Blog Post: cleantestresults XML Snippet

    About a year ago, I wrote about an automated way to clean up the TestResults folder created by VSTS. While I still use this approach methodically, I've begun to find it tedious to find my original post to copy and paste the XML into the project file. For this reason, I've created an XML code snippet...
  • Blog Post: Testing Against The Passage of Time

    This is the fourth in a small series of posts about testing against non-determinism. In this installation, I'm going to cover the passage of time. In my former post , I demonstrated how you can use the Provider Injection pattern to decouple your test target from a direct dependency of the current...
  • Blog Post: Vote For Generic Set Class

    From time to time, I find myself in a situation where I need a class that mimics the behavior of a mathematical set: Elements are unordered An element can only appear once Sets can interact via Union, Intersect, Difference, IsSubset, IsSuperset, etc. It's not that writing such a class...
  • Blog Post: Vertical Guidelines in Visual Studio

    From time to time, I've found myself wishing that Visual Studio had vertical guidelines in the code editor. This may not apply to all developers, but in some scenarios, I'd really like to have a visual right border when writing code. In my case, it's typically when I'm writing sample code for publication...
  • Blog Post: Generating NotImplementedException Instead Of Exception

    Ever since I started using Visual Studio 2005, I've been enjoying its refactoring features, but it has always been bugging me that when you generate a new method stub or implement an interface or abstract class, the auto-generated method throws System.Exception instead of NotImplementedException. However...
  • Blog Post: Test-Driven Development With Test Lists

    For most of the time, I write code using the test-driven development methodology. This means that I write a bit of code, run a suite of tests, write a bit more code, run some more tests, etc. For this reason, I need unit testing to be an integrated part of my development experience: It should be integrated...
  • Blog Post: Debugging When Property Reads Have Side Effects

    The last couple of days, I've been working with some code where there was a side effect when a particular property was read. This made it more cumbersome to debug the code, until a very simple solution dawned on me. It's so stupidly simple that I suspect I'm the last person to ever discover it, but I...
  • Blog Post: Cleaning Away The TestResults Folder

    When I write code, I usually use the test-driven development approach, which means that I execute a suite of unit tests very often. In Visual Studio 2005, all artifacts of a test run gets copied to a folder beneath the TestResults folder, which is usually placed at the same level as the solution files...
  • Blog Post: Bordecal.ImportsSorter

    Being the somewhat anal-retentive person that I am, I have always found it important to have all my using statements in an ordered sequence, and finally seem to have settled on plain alphabetical sorting. A manual approach to this worked fine for me in Visual Studio 2003, since in any case I had to...
Page 1 of 2 (29 items) 12