[NoBrainer] Start-Sleep takes longer that it seems

While doing some tests with our new TraceListener and log server I did some tests where I wanted to find out how long the log server would take to start accepting messages. So I started to constantly send messages from the console: When I looked at the server logs I noticed that the arriving messages […]

[NoBrainer] Using TeamCity Build Parameters with Environment Variables in C#

TeamCitiy Build Configuraiion Environment Variables

When integrating back end systems we very often would like our build server to run integration tests against our test evironments. The problem is that we do not want to hard code any connection uris (or even worse credentials) into our unit and integration tests. As we are using TeamCity as our build server (again […]

[NoBrainer] Getting constructor information with PowerShell 5 easily

Before PowerShell 5 we had to revert to reflection to be able to display constructor information in PowerShell (see Get-Constructor Fun for details). And because we used that functionality so often we created a Cmdlet Get-Constructor that is part of our biz.dfch.PS.System.Utilities module. However with PowerShell 5 this is obsolete as it is now built […]

[NoBrainer] Avoiding Concurrency Exceptions when working with a DataServiceContext in PowerShell

When working with a DataServiceContext from PowerShell you might run into concurrency update situations after updating entities via SaveChanges. This is due to the behaviour of the DataServiceContext ChangeTracker which will not reflect changes performed by the server (as a result of our update operation). Let me illustrate this with a quick example: Suppose we […]

[NoBrainer] PowerShell and Broken TabCompletion

Fusion Log Viewer

The other day I was working in a PowerShell session when I suddenly realised that Powershell’s TabCompletion feature was no longer working. That was strange, as it certainly normally and definitely worked before. And of course, I did not change anything – so I thought. After a quick look at lmgtfy did not show any […]

[NoBrainer] PUT/PATCH/MERGE with OData Service Client

Visual Studio supports the generation of data service clients (Service references) for OData services. A data service client is a .NET class that contains methods for accessing the OData service and gets generated based on the metadata provided by the OData service. The client acts as a proxy and translates the method calls into HTTP […]

[NoBrainer] Mocking DateTimeOffset and DateTime with Telerik JustMock return unexpected values

JustMock DateTimeOffset

Today’s post goes rather quick … Telerik JustMock in its commercial (i.e. non-free) version provides you the option to mock static classes, which comes in really handy when you want to mock something like DateTimeOffset. However, in our scenario it yielded some surprising results… In my project I needed to mock a DateTimeOffset to have […]

[NoBrainer] Code Contracts in Interfaces with abstract base classes will not trigger if override is not specified

Today I ran into a problem when all of a sudden my code contracts stopped working – as it seemed. In reality I was missing a simple override in the implementation of a class that derived from a base class. But now for a a concrete example. Suppose you have the following scenario: ContractClassForIArbitraryObject this […]

[NoBrainer] ‘The Should command may only be used inside a Describe block’ when run in an interactive PowerShell session

Here is a small helper method that you can use when creating Pester tests and trying to run them in an interactive PowerShell session. When executing statements that include the Pester Should Cmdlet interactively in a PowerShell session you receive the following error message: With the Should helper method below you can still execute the […]

[NoBrainer] C# UnitTesting with CodeContracts and Telerik JustMock

When using Microsoft CodeContracts your Contract.Requires and Contract.Ensures statements will throw a ContractException which you cannot catch (per design). This means that you cannot use the [ExceptedException] attribute to assert them. Furthermore when mocking with Telerik Justock you cannot use Contract.Ensures and Contract.Requires at all in your stubs, as the stub is expected to be […]