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 […]
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 class holds the contract for […]
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 original Pester statement without having […]
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 a Func in the form […]
While doing some performance optimisations on one our loader scripts I came across an issue of converting a System.Guid or [[Guid]] in PowerShell to a string representation. In C# I was always (and still am) using ToString() and never saw anything like a Guid property. However, for some reason in PowerShell I tended to use the Guid property (instead of […]
The following xml-file describes the Allman code style for IntelliJ IDEA and the Java-File below shows an example of the code style. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden […]
Recently I needed to check if a function was defined inside a script file. Reflection was my first thought, and PowerShell being a first class .NET citizen should be able to perform this. But as PowerShell is defined as an Abstract Syntax Tree (AST) it is even easier to achieve this. Inside the AST every block (BEGIN, PROCESS, END) is […]
Some time ago I mentioned an error and a possible workaround when using PowerShell with the Clickatell SOAP interface. As Clickatell now provides a REST based interface I thought it is time to quickly show you how to use this API instead. Description When sending SMS you certainly first have to enable the REST API in your developer central account. […]
This post describes how you can extend the Graylog2 AlertCondition mechanism to raise alerts based on the contents of a field (instead of just a message count or a field value). Introduction Currently Graylog2 only allows you to trigger AlarmCallbacks based on either MESSAGE_COUNT Here you define how many messages must be assigned to that stream before an alarm will […]
Recently I was testing Graylog2 as a store for metering data and had to bulk-load a larger amount of data into its database. My goal was to create synthetic and […]
Today I had to pass a long list of parameters to a Cmdlet inside a PowerShell job. At first it looked like this, which seemed rather horrbile (i.e. unreadable) to me. There had to be a cleaner approach to this – and so it was … there are some samples around the Internet on how to use the Start-Job Cmdlet […]
As announced a couple of days ago we started pushing some of our PowerShell modules to GitHub and NuGet. And soon it became obvious that keeping all the scripts, signatures, versions and packages in sync was some tedious and error-prone work. This should definitely be automated, you might instantly think – and right you are! So here are some small […]
[Note] This is a rather old article from 2014. The world and PowerShell have changed. For an even easier way than presented here see the comment at the bottom of the article. In this post I present a quick refresher on how to make C# extension methods available to objects and classes in PowerShell sessions. C# allows you to extend […]
This one bit me, when trying to convert the inline help of a PowerShell cmdlet into some markdown enriched code for Github. For the PowerShell modules and Cmdlet we publish at github we sometimes use the integrated Wiki pages from Github to have some documentation on their use. We often also extract the full inline help and paste it to […]
Today I show you how you can quickly use “JayData” to modify the contents of a LightSwitch HTML “drop-down list” (aka “choiceList”). Though it does not really offer all the blows and whistles as other controls such as “select2” it has some advantages like easy setup and good visual integration. And now with the use of JayData (and certainly with […]
I recently wrote on how you can call ODATA actions via PowerShell. However, sometimes these actions return entity types that you cannot resolve easily in PowerShell. Normally you would resort to “Execute()”, but this is neither easily doable in PowerShell. But as most usual there is another way around this. Instead of using “Execute()” to retrieve the data you rely […]