Skip to main content

Posts

Verifying Mock Parameters

Found a use case for a feature of the .NET mocking framework Moq that may not be that well known, and was new to me at least. I had a method under test that - via a number of overloaded extension methods - called an underlying method in the Umbraco CMS. The details aren't really important, but specifically it was the method GetImageUrl on IImageUrlGenerator that I was mocking to return a known output. I was then testing how my method used that result it in it's processing. I could see the method failing when I had a setup like this: But passed with this: So clearly we weren't passing in the Height parameter that I was expecting. One way to solve this would be to get the Umbraco code locally and step into it, but I found another way that I read about on this closed issue for the Moq library. It provides a means of capturing the parameters passed to a mocked method, and then establishing what they are via a breakpoint or logging. That revealed that so
Recent posts

Upgrading Terraform Resources

One of the projects I currently work on consists of a few components - an API, a worker process, a couple of web applications and a serverless functions app - all of which are deployed to Azure using infrastrure as code defined as Terraform resources . We have recently been upgrading it from .NET 6 to .NET 8 and hit an issue when we tried to update the framework definition of the Azure app service resources defined in Terraform. The attribute in question only accepted up to .NET 6. The reason is that the resource we were using - azurerm_app_service - is now deprecated and replaced with azurerm_windows_web_app (or azurerm_linux_web_app ). It was a similar case for the app service plan ( azurerm_app_service_plan replaced with azurerm_service_plan ) and the functions app ( azurerm_function_app replaced with azurerm_windows_function_app ). Naively, my first thought was to just update our infrastructure configuration to use the newer resources, and deploy that update. However, don

Adding and Deleting Criteria

This is one of a series of posts looking at migrating Umbraco packages to Umbraco 14 and the new backoffice. Other posts in this series: Introduction Upgrading to Umbraco 14 Preview Creating a Property Editor With Umbraco 14 Adding and Deleting Criteria As of last time I posted in this series, I had a partially working property editor for Personalisation Groups. It could display the information stored against the property, and I'd solved a couple of challenges around retrieving external data and injecting scripts dynaically at runtime. There's not been too much progress since, but I've picked up a few more things along the way that I'll include as a bit of a "grab-bag" in this post. First step to make the data editable was wiring up some button clicks. In angularjs we are used to: <button type="button" ng-click="delete($index)">Delete</button> With Lit, the syntax is: <button type="b

Creating a Property Editor With Umbraco 14

This is one of a series of posts looking at migrating Umbraco packages to Umbraco 14 and the new backoffice. Other posts in this series: Introduction Upgrading to Umbraco 14 Preview Creating a Property Editor With Umbraco 14 Adding and Deleting Criteria A "Hello World" Property Editor The Umbraco documentation is a good guide for getting started, with details on creating an extension and creating a property editor . Using the scripts provided I created an extension within a folder created in my main package project that I called client-src . npm create vite@latest -- --template lit-ts personalisation-groups cd personalisation-groups npm install npm install -D @umbraco-cms/backoffice@next This sets up some files that make up an extension to the backoffice, using the latest preview release from the Umbraco prereleases feed. Next step as described in the docs is to add a vite.config.ts file. I set mine up to export the built files rather than to t

Upgrading to Umbraco 14 Preview

This is one of a series of posts looking at migrating Umbraco packages to Umbraco 14 and the new backoffice. Other posts in this series: Introduction Upgrading to Umbraco 14 Preview Creating a Property Editor With Umbraco 14 Adding and Deleting Criteria Prerequisites As indicated in the official documentation , to work with Umbraco 14 it's likely your development machine needs some updates, which was the case for me. You'll need: To be running .NET 8, which is available at the time of writing in a first release candidate . To be on at least the v17.8 latest preview version of Visual Studio. To download and install this you may need to change the channel used by the installer . To install a minimum version of Node.js 18.16. I have Node Version Manager for Windows installed, which is handy tool both for installing new versions and also switching between versions that you may need for different projects. Package Update The package I'm worki