ploeh blog

Mark Seemann's discontinued .NET blog.

Browse by Tags

Tagged Content List
  • Blog Post: Faking The Windows Azure Table Service

    When presented with a new technology, one of my primary evaluation criteria is its testability, so it should come as no surprise to the regular reader of this blog that this was also foremost in my mind when Windows Azure was presented at PDC. Much of the Azure Services Platform is just .NET, so testability...
  • Blog Post: A General-Purpose Fake ADO.NET Data Service

    In my previous post , I discussed how to implement a Fake ADO.NET Data Service for use with unit testing, showing how you can develop a one-off service that addresses specific needs, such as querying parents and children in the example. As I hinted in that post, it's possible to create a reusable...
  • Blog Post: Creating A Fake ADO.NET Data Service

    Previously , I discussed unit testing ADO.NET Data Service clients using a Fake ADO.NET Data Service, and I promised to demonstrate how to create such a service. In this article I will continue the previous example and implement the Fake MyService class. The basics of MyService is pretty simple: ...
  • Blog Post: Unit Testing ADO.NET Data Service Clients

    In my previous post , I discussed unit testing ADO.NET Data Services and how you can host and test the service itself. In this post, I'll take a look at the opposite scenario: You have a client of an ADO.NET Data Service, and you want to unit test the client without relying on the real, production service...
  • Blog Post: Unit Testing ADO.NET Data Services

    ADO.NET Data Services enables you to expose data (including, but not limited to, relational data) as REST services. Since it's built on top of WCF, it can be tested utilizing similar techniques , but allow me to elaborate a bit on the subject. As with WCF, you might be interested in testing one or...
  • 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: Assert.Throws

    xUnit.net provides the Assert.Throws method for testing exceptions, instead of the ExpectedException attribute. In his original announcement , James Newkirk explains why this is a much better approach, and I can only agree. However, those of us that for one reason or another use MSTest are currently...
  • Blog Post: Naming SUT Test Variables

    If you are a regular reader of this blog, you may have noticed that for the last couple of months, every test I've posted has shared some similarities; one of which is that I always name my SUT test variable sut . Here's a simple example: [ TestMethod ] public void DoStuffWillReturnMessage() ...
  • Blog Post: Testing Against the Real Event Log

    Lots of applications write to the Windows Event Log. When TDD'ing, event logging is part of an application's Indirect Output , so to verify that logging happens correctly, you need to verify the test against an Observation Point . As always, the correct approach to this requirement is to inject some...
  • Blog Post: SqlExpressDatabaseInstaller

    When unit testing data access components, I prefer to test against run-time components that match the target environment as closely as possible. In other words, if the data access component targets SQL Server 2008, I prefer to test against a SQL Server 2008 database. In a number of earlier posts , I...
  • Blog Post: An Overview of Unit Testing Duplex WCF Services and Clients

    In the last couple of posts, I've demonstrated how to isolate implementation from WCF contract definition and behavior in a duplex communication scenario. These posts have been rather detailed, so it occurred to me that you might benefit from an overview. The main goal was to ensure testability of...
  • Blog Post: Unit Testing Duplex WCF Clients

    In my previous post , I explained how to unit test a WCF service with callbacks. Since the scenario involves duplex communication, the service is also a client, and vice versa, so it's only reasonable to look at the 'client' as well, to examine how to best approach unit testing such a beast. Since...
  • Blog Post: Unit Testing Duplex WCF Services

    One of my readers recently asked me about unit testing WCF services when they have callbacks. Given that I strongly believe that you should attempt to implement your services without referencing WCF at all , but duplex WCF services require you to get the callback instance from OperationContext.Current...
  • Blog Post: Implementing WCF Services Without Referencing WCF

    More than a year ago, I wrote my first post on unit testing WCF services . One of my points back then was that you have to be careful that the service implementation doesn't use any of the services provided by the WCF runtime environment (if you want to keep the service testable). As soon as you invoke...
  • Blog Post: Test-Specific APIs With Extension Methods

    Writing maintainable tests that clearly communicate intent can sometimes be a challenging undertaking. Ideally, a unit test suite should act as executable documentation and be robust when faced with refactoring of the SUT . Some software lends itself quite naturally towards clear and concise test code...
  • Blog Post: Unit Testing Anti-Pattern #2: Not Covering Bugs In Your Tests With Tests

    Roy just posted a unit testing anti-pattern based on his personal experience. I'd like to follow up with one from my own personal experience: A few days ago, while working with one of our unit test suites, I discovered that one of my test utility classes had a bug. The bug didn't cause any tests to...
Page 1 of 3 (65 items) 123