Umbracokalaset 2024

/media/wm0dkbhh/img_9182.jpg

Earlier this week, I had the opportunity to be part of Umbracokalaset 2024, an event that brought together the Swedish Umbraco community in Stockholm. Organized by Toxic Interactive Solutions, in collaboration with Obviuse and Umbraco, the event was all about sharing knowledge and strengthening the Umbraco community.…

.NET Aspire Lightning Talk Stockholm

/media/iplktoxc/ska-rmavbild-2024-06-27-kl-180435.png

I had the pleasure of hosting a lightning talk about .NET hashtag#Aspire today at Knowit Experience's Dev Day in Stockholm. A big thank you to everyone who attended and for all the great questions and buzz around .NET Aspire.…

Integrating Machine Learning and AI Predictions in Umbraco with ML.NET

/media/0cups4dg/ska-rmavbild-2024-06-24-kl-141010.png

Helping users find their way and provide them with quick and accurate answers to their questions is crucial for enhancing user experience and engagement. By integrating machine learning into your CMS, such as Umbraco, you can offer users intelligent predictions based on existing content.  In this blog post I will show how I implemented machine learning in Umbraco using ML.NET, enabling users to find the most relevant FAQ answers using AI predictions.…

Dev Day GBG: Summary!

/media/ftxh0sgp/ska-rmavbild-2024-06-20-kl-083518.png

I recently had the pleasure of co-organizing Dev Day in Gothenburg together with my good friend David Skoog, and what an incredible day it turned out to be! The event brought together Knowit developers to share knowledge, collaborate and be inspired. …

ML.NET Lightning Talk Gothenburg

Last week, I had the opportunity to host a Lightning Talk at Knowit Experience Gothenburg, introducing the team to the basics of ML.NET and how to get started with machine learning.…

Machine Learning for .NET Developers: How to build your own AI using ML.NET

/media/0zdhqv1x/ai.webp

Artificial Intelligence (AI) is transforming the way we develop applications. As a .NET developer, you can use ML.NET from Microsoft to integrate machine learning (ML) into your .NET applications. In this blog post, I’ll walk you through creating a simple AI application using ML.NET in less than 5 minutes.…

Speaker at dot.festival in Oslo on .NET Aspire: The future of .NET

/media/esoldlig/ska-rmavbild-2024-05-31-kl-192214.png

Today me and John Beijar went to Oslo to visit dot.festival where we joined 140+ attendees from Norway, Sweden, Denmark, Finland and Poland, discussing how we want to shape future digital solutions and the responsibility we have as digital creators. …

Oslo Umbraco Meetup speaker on .NET Aspire

/media/lznfvndp/1715878016627.jpeg

I recently had the pleasure of speaking at the Umbraco Meetup in Oslo, where I talked about how .NET Aspire, Microsoft's latest love child, can be effectively combined with Umbraco in a microservice architecture.…

Elmah.io Lightning Talk

I recently had the pleasure of hosting a Lightning Talk at Knowit Experience in Gothenburg, where we dove into the world of logging tools with focus on elmah.io. elmah.io is the easy error logging and uptime monitoring service for .NET.…

.NET Aspire Lightning Talk Gothenburg

Since I returned to Knowit Experience as the new Head of Tech we’ve introduced a new speaker format called ”Tech Fika” in Gothenburg. This is a bi-weekly opportunity for anyone in the tech skill to share whatever they like in an unpretentious ”mini lightning talk” format.…

5 minute introduction to Message-Based Communication with Azure Service Bus

In this short blogpost we're diving into the world of message-based communication, particularly focusing on Azure Service Bus. If you've primarily worked with request-response communication models, you're in for a treat. Message-based communication can be an extremely powerful addition to your toolbox and Azure Service Bus makes it exceptionally straightforward.…

Unit Testing with ChatGPT

/media/yinjlmhc/capture-unit2.png

Don't like writing unit tests or simply don't have the time for it? Good news – now you don't have to! As a newbord AI enthusiast with a long-time obsession with unit testing, I couldn't resist the urge to try and combine these two topics. Check out my latest blog post "Unit Testing with ChatGPT," to discover how you can use ChatGPT to generate test cases and code for you.…

Asserting Equal vs Same vs Equivalent

/media/nonjzvlr/equal-same-equivalent.png

In this article, I'm going to demonstrate three very common but possibly confusing assertion differences in the world of C# testing: Assert.AreEqual, Assert.AreSame and Should().BeEquivalentTo.…

Custom Umbraco NotificationHandlers

/media/iagckqxq/cover-20.png

Whenever a content item is published in Umbraco a ContentPublishingNotification event will be triggered. By creating our own NotificationHandler we can hijack this event and cancel or extend the default notification when a user is publishing a content node in Umbraco.…

Using The Builder Pattern to improve Testability and Readability

/media/45wkldxg/cover-21.png

Sometimes setting things up can get a bit messy, especially when we want to test coupled code with a lot of dependencies. This is where the Builder Pattern comes in handy - it helps us create objects in an easier and cleaner way, especially when they are a bit complex to set up.…

Tutorial: How to get started with .NET Aspire & Umbraco 13

/media/2w1jrpuf/cover-24.png

.NET Aspire, the latest iteration in the .NET family, offers a modular, high-performance framework for building web applications.…

Tutorial: How to migrate an existing Umbraco website to .NET Aspire

/media/2u4ola52/cover-25.png

In my previous article I shared a tutorial on how you can get started with .NET Aspire with a brand new Umbraco 13 website running on .NET 8. In this follow-up tutorial I'll cover how you can make the same transition to .NET Aspire but with an existing pre-Umbraco 13 website.…

Guest on tech Podcast 'Digitalterapi'

/media/iskakfua/screen-shot-2022-03-15-at-12-39-09.png

Last week I was a guest on tech podcast “Digitalterapi” talking about Umbraco, Open Source, Community and much much more..…

Moving smoothly between Optimizely and Umbraco CMS

/media/xtqdy5fn/screen-shot-2022-03-18-at-08-33-44.png

As I mentioned in one of my previous posts, I had a presentation planned at a lunch meetup in the Knowit Gothenburg office, called "The Optimizely developers guide to Umbraco".…

C# 8.0 Default interface methods in under 60 seconds!

Last week I noticed a new feature in C# 8.0 called Default Interface Methods. Although the official documentation is great, it's quite extensive so I thought I would do this really short and simple breakdown of what this feature enables.…

Using TestRunParameters in your NUnit tests using .runsettings

/media/gd5jlv11/runsettings9.png

I've been getting a lot of traffic lately related to the google search phrase "nunit runsettings example" which at the moment leads to this blogpost I wrote on how to use Playwright with NUnit, which doesn't really cover how to set up .runsettings but rather how you can toggle headless mode in Playwright (totally different topic). So I thought I would share a little tutorial on how you can set up a new NUnit project and use .runsettings and TestRunParameters in your tests.…

Logging HttpRequests using DelegatingHandler with a named HttpClient and HttpMessageHandlers in Umbraco

Ever found yourself logging the same things over and over again in your Umbraco application when doing HttpClient requests? Wouldn't it be nice (if we could wake up) and all of our request where automatically logged for us in one unified way throughout our entire application?…

5th year teaching .NET Testing at local university college YRGO

/media/fixj5hso/yrgo1.jpg

Today I had the privilege of lecturing for the 5th year at Yrgo University college on the subject of .NET Testing. As always, the goal has been to give students a positive impression of testing early in their career and that writing tests is not something you "should" or "must" do but something you WANT to do because it is a fun and challenging part of being a developer.…

NUnit tests is not found or do not run in Visual Studio's Test Explorer

Having problems with your NUnit tests not running as expected in Visual Studio's Test Explorer? Even wiered, the tests might work for other members of your team but for some reason not for you?…

Comparing mocking frameworks: How to handle optional parameter with NSubstituite, Moq and FakeItEasy

/media/1g4men0w/main.png

Depending on which mocking framework you are using you might have to handle optional parameters differently and in this short article I will compare and demonstrate the differences in the three major mocking frameworks NSubstitute, Moq and FakeItEasy.…

Loading this assembly would produce a different grant set from other instances

The other day one of our legacy applications threw this strange error during a production deploy: "Loading this assembly would produce a different grant set from other instances". This .NET 4.6 application is a load balanced SOAP API and strangely this only occured on 1 of the 3 frontend servers so when browsing the frontend it initially seems healty but every other random request would fail and show this error.…

How to set TransactionScope timeout in code, application and server wide

The other day we got a bunch of these transaction exceptions logged on some of our production servers: "The operation is not valid for the state of the transaction". At first this exception was a bit cryptic, but when investigating it further is had this following inner exception: "Transaction Timeout".…

Loose vs. Strict mocking behaviour

I thought I would demonstrate the difference between Loose and Strict mocking behaviour when using the Moq Framework. By default when you create a new mock and don't specify a MockBehaviour it will be assigned MockBehaviour.Default, which equals to MockBehaviour.Loose.…

Moq vs. NSubstitute vs. FakeItEasy

Today I though I would do some syntax comparison between a few of the biggest Mocking Framework in .NET: Moq, NSubstitute and FakeItEasy. Although these framework have slight functional differences they pretty much do the same thing but in different syntax and lingo.…

Tutorial: How to setup a .NET Minimal API with integration testing using WebApplication Factory and NUnit

/media/ymnazl3f/cover-new.png

In this article I will share how you can setup an API using less than 20 lines of code using .NET Minimal API. Next we are going to setup an NUnit test project and using .NET WebApplicationFactory we will call the API endpoint and parse the resonse as an products array and compare the actual response to an expected json file embedded in our source code.…

Adding an API Security Definition and Requirement using Swagger UI

/media/ytoby1u3/cover-3.png

In this tutorial I will cover how you can setup an API with Swagger and then add security definition and requirement to pass an api token as an http header with every API request. Lets get to it!…

Using the Fluent Builder Pattern to improve test readability and maintenance

/media/es2iqvns/cover-5.png

Using this pattern we create an test object builder that will centralize redundant (and sometimes complex) logic that we don’t want to have in each and every one of our tests. This will make our tests slimmer and more focused on what is actually important for the state of which is being tested.…

Unit Testing private methods in C#

/media/jnjp3wqc/cover-7.png

Should private methods in C# be Unit Tested? Generally you don’t write unit tests for private methods since they are not accessed from outside the implementation class (private methods are considered implementation detail).…

Add a reference to ".NETFramework,Version=x" in the "TargetFrameworks" property of your project file and then re-run NuGet restore?

/media/nf0h5m20/cover-9.png

Sometimes when upgrading .NET framework versions you might get this really strange error in Visual Studio: -"Add a reference to ".NETFramework,Version=v4.8" in the "TargetFrameworks" property of your project file and then re-run NuGet restore?"…

Getting started with Snapshot Testing using NUnit and Snapper

/media/blbj0m3p/cover-12.png

Snapshot testing is a valuable technique for testing software applications. Using this technique we can capture the state of an application at a specific point in time and compare it to a previously recorded state, known as a snapshot.…

Unit vs. Integration Testing

/media/zcbprouj/cover-17.png

By understanding the essential differences between unit and integration testing, we as developers can make better decisions about when and how to use each type of testing to ensure the quality and reliability of our software.…

Showing a maintenance banner on your Umbraco site

Something we do for most of our sites is setting what we call a deploy flag during our deployments and then have our frontend render a maintenance banner at the top of the website. By showing a maintenance banner we can inform the visitor that at the moment we are performing planned maintenance and that they might experience disturbances.…

Testing the untestable with the Adapter Design Pattern

During my session at last weeks Codegarden on ‘Getting started with Unit Testing in Umbraco’ I got a really good question in the Q&A afterwards, and I thought I would share the question and elaborate on my answer: -“What tips do you have for mocking services that are overly complex or have lots of dependencies that can't be null?”…

Umbraco v9 findings

This week I had a little room left in my schedule for studying new tech and obviously I took that time to get up to speed on Umbraco’s new major version built on dotnet core.…

Using Microsoft Playwright and NUnit to automate search behaviour

/media/t4edno4o/cover-13.png

I have been experimenting a lot with different UI testing frameworks such as Selenium, Cypress and Playwright in a public GitHub project and I’ve really come to fancy Microsoft.Playwright for .NET in combination with NUnit.…

Comparing different UI Testing frameworks (Selenium, Cypress and Microsoft Playwright)

So I decided that 2022 would be the year when I will start to implement more UI Testing in my projects. But, which framework should I choose?…

Trust your tests!

Tests are meant to replace our browser clicking and instead give us instant and reliable feedback if our code is working or not. The browser is just a presentation layer. Trust your tests!…

Integrating Papertrail logging in a .NET (NLog) application

/media/1spfiuir/screen-shot-2022-03-01-at-15-10-11.png

I’ve really come to enjoy Papertrail as an online log viewer. It’s super quick to setup and I can manage and view logs from multiple project and environments in one simple UI with searching, filtering etc.…

THE OPTIMIZELY DEVELOPERS GUIDE TO UMBRACO

/media/od1goyb0/pres.png

Next week I'll be doing a talk at Knowit on how to move smoothly between Optimizely (Episerver) and Umbraco from a developers perspective. This is a presentation I've planned on doing for years and finally got around to.…

How to test internal classes

/media/wnxhvrb1/cover-6.png

When you're writing unit tests you may sometimes find yourself in a situation where you need to be able to access an internal class from within another project such as your *.Tests project.…

Parallelism: NUnit vs. xUnit

Running your tests in parallel can significantly improve the speed of your test runs, but it could give you occasional problems especially if you're working on static implementations. Also turns out that depending on which testing framework you're using parallelism might be handled differently.…

Starting to Unit Test: Not as Hard as You Think

I thought I would share a recommendation for a really great book that I think anyone who is new to Unit Testing should read: Starting to Unit Test: Not as Hard as You Think by Erik Deitrich. I read this book many years ago but I remember it to this day because it was an eye opener to what Unit Testing essentially is.…