Skip to content

Instantly share code, notes, and snippets.

View jawood1's full-sized avatar

Jonathan Wood jawood1

View GitHub Profile
@jawood1
jawood1 / UmbracoBasedControllerTests.cs
Last active October 23, 2025 10:35
Base class for testing Umbraco-based controllers with ASP.NET Core. Provides a method to create mocked IFeatureCollection with UmbracoRouteValues, allowing access to CurrentPage in controller tests. Includes proper setup for HTTP request/response features.
namespace YourNameSpace.Test.Helpers;
using System.Net.Mime;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Controllers;
using Moq;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Web.Common.Routing;
@jawood1
jawood1 / UmbracoMockHelper.cs
Last active October 30, 2025 11:07
A helper class for creating mocked Umbraco objects for unit testing. Includes methods for mocking IPublishedContent, IPublishedElement, BlockList/BlockGrid items, MediaWithCrops, UmbracoHelper, and URL providers using Moq.
namespace YourNameSpace.Test.Helpers;
using Moq;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Dictionary;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Blocks;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors.ValueConverters;
using Umbraco.Cms.Core.Routing;
@jawood1
jawood1 / Optimize-AzureBlobImages.ps1
Created November 14, 2022 13:41
Azure Blob Storage Image Bulk Optimization - https://automys.com/library/asset/azure-blob-storage-image-bulk-optimization - Updated to work with AZ (2022) and additional conditioning
<#
.SYNOPSIS
Optimizes image file size for all PNG and JPG images in a Microsoft Azure blob storage
container by processing them locally and replacing their content with the optimized result.
.DESCRIPTION
Image files are often needlessly oversized and can be compressed without quality loss using
widely-available utilities. Microsoft Azure provides a blob storage service that can be used
to host publicly-accessible images for websites or other purposes. For containers with large
numbers of suboptimal images or for bulk optimization, this script optimizes all images in