public void ImageSourceValidation() { ResetHostingDir(); using var stream = _imageFile.OpenStream(); var ex = Assert.ThrowsException <ArgumentException>(() => { _host.Add(stream, new ImageOptions { ValidateSource = i => { if (i.Width > 500 || i.Height > 500) { throw new ArgumentException("Image is too large"); } }, }); }); ex.Message.ShouldBe("Image is too large"); }