Using Generic Test Classes and EntityFramework test doubles to facilitate Unit Testing

This is some kind of follow-up to my previous posts regarding generic Odata controllers and decoupled domain managers. If you have followed my posts Using Dependency Injection with StructureMap to decouple business logic from WebApi OData Controllers and Simplifying OData Controllers by using generic controller classes you will remember that we use managers that contain […]

[NoBrainer] Running ad-hoc benchmarks with BenchmarkDotNet and C# Scripting (CSI)

Creating benchmarks with BenchmarkDotNet is very easy and running them is even easier with the Visual C# Interactive Compiler (CSI for short). If you need more information about CSI, read Essential .NET – C# Scripting to get started). And here is how it works: Select the Developer Command Prompt for VS2015 from the Start Menu […]

[HOWTO] Create LocalDB File (.mdf) manually in Visual Studio 2015

If you are using LocalDB and want to create an empty database you should perform the following steps. Go to Visual Studio Server Explorer | Data Connections Select Add Connection from the context menu Change Data Source to Microsoft SQL Server Database File (i.e. LocalDB) Set the Database file name by entering a database name […]

Replacing MEF with StructureMap

The title of today’s post might sound a little bit provoking, as originally MEF and StructureMap are not meant for the same use cases. However, as there is a great deal of overlapping functionality in StructureMap over MEF (and chances are high one is using an IoC framework anyway), it makes sense to check if […]

[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 […]

Logging in PowerShell with System.Diagnostics.TraceSource and log4net

Microsoft .NET offers a very flexible logging system exposed via the System.Diagnostics namespace. Unfortunately (and not surprisingly), by default the pre-packaged listeners do not support writing messages to log4net directly. However, we can extend the logging outputs by implementing custom TraceListeners and when asking our favourite search engine for “TraceListener log4net” we find there are […]

[HOWTO] Automatically applying PSDefaultValue to C# based PSCmdlet Parameters

One of the cool features of PowerShell script based Cmdlets is the possibility to define default values for Cmdlet parameters. This is typically done like this: Whenever we invoke such a Cmdlet without specifying the Name parameter the PowerShell runtime will insert the value my default value into that parameter. C# based PSCmdlet provide a […]

Unit Testing C# binary PowerShell Modules

For years all our PowerShell modules we released were script modules (i.e. they were written in PowerShell). However, it is certainly possible to write PowerShell modules in C# as binary modules. Of course there are already plenty discussions whether one or the other approach is better. It really depends on the exact requirements. For us […]

[HOWTO] Sign PDF with SuisseID

Screenshot - Sign PDF with Open eGov LocalSigner

Today I had some troubles signing a PDF document with my SuisseID (Smart card version). I first tried to sign the PDF document by using Adobe Acrobat Reader DC. Unfortunately the Adobe Acrobat Reader DC started hanging during the saving process of the signed document. Nevertheless the document got saved but the signature was invalid. […]

[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 […]