Skip to content

Commit

Permalink
Missed the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drpeck committed Aug 30, 2024
1 parent 1fd344a commit 3a547d7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Our.Umbraco.TagHelpers.Tests/InlineSvgTagHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using NUnit.Framework;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void Setup()
public void NoOutputIfNoMediaOrFileSet()
{

var tagHelper = new InlineSvgTagHelper(null, null, null, _settings, null);
var tagHelper = new InlineSvgTagHelper(null, null, null, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>());

tagHelper.Process(_context, _output);

Expand All @@ -67,7 +68,7 @@ public void NoOutputIfNoMediaOrFileSet()
public void NoOutputIfBothMediaAndFileSet()
{
var umbContent = Mock.Of<IPublishedContent>(c => c.ContentType.ItemType == PublishedItemType.Media);
var tagHelper = new InlineSvgTagHelper(null, null, null, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, null, null, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
FileSource = "test.svg",
MediaItem = umbContent
Expand All @@ -81,7 +82,7 @@ public void NoOutputIfBothMediaAndFileSet()
[Test]
public void NoOutputIfFileNotSvg()
{
var tagHelper = new InlineSvgTagHelper(null, null, null, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, null, null, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
FileSource = "test.notsvg"
};
Expand All @@ -97,7 +98,7 @@ public void NoOutputIfFileNotFound()
var fileProvider = new Mock<IFileProvider>();
fileProvider.Setup(p => p.GetFileInfo(It.IsAny<string>())).Returns(Mock.Of<IFileInfo>(f => !f.Exists));
var hostEnv = Mock.Of<IWebHostEnvironment>(e => e.WebRootFileProvider == fileProvider.Object);
var tagHelper = new InlineSvgTagHelper(null, hostEnv, null, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, hostEnv, null, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
FileSource = "test.svg"
};
Expand All @@ -113,7 +114,7 @@ public void ExpectedOutputIfValidFile()
var fileProvider = new Mock<IFileProvider>();
fileProvider.Setup(p => p.GetFileInfo(It.IsAny<string>())).Returns(Mock.Of<IFileInfo>(f => f.Exists && f.CreateReadStream() == new MemoryStream(Encoding.UTF8.GetBytes("test svg"))));
var hostEnv = Mock.Of<IWebHostEnvironment>(e => e.WebRootFileProvider == fileProvider.Object);
var tagHelper = new InlineSvgTagHelper(null, hostEnv, null, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, hostEnv, null, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
FileSource = "test.svg"
};
Expand All @@ -131,7 +132,7 @@ public void NoOutputIfMediaUrlNull()
{
var urlProvider = new Mock<IPublishedUrlProvider>();
urlProvider.Setup(p => p.GetMediaUrl(It.IsAny<IPublishedContent>(), It.IsAny<UrlMode>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Uri>())).Returns((string)null!);
var tagHelper = new InlineSvgTagHelper(null, null, urlProvider.Object, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, null, urlProvider.Object, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
MediaItem = Mock.Of<IPublishedContent>(c => c.ContentType.ItemType == PublishedItemType.Media)
};
Expand All @@ -147,7 +148,7 @@ public void NoOutputIfMediaNotSvg()
var umbContent = Mock.Of<IPublishedContent>(c => c.ContentType.ItemType == PublishedItemType.Media);
var urlProvider = new Mock<IPublishedUrlProvider>();
urlProvider.Setup(p => p.GetMediaUrl(umbContent, It.IsAny<UrlMode>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Uri>())).Returns("test.notsvg");
var tagHelper = new InlineSvgTagHelper(null, null, urlProvider.Object, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, null, urlProvider.Object, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
MediaItem = umbContent
};
Expand All @@ -169,7 +170,8 @@ public void NoOutputIfMediaNotFound()
null,
urlProvider.Object,
_settings,
null)
null,
Mock.Of<ILogger<InlineSvgTagHelper>>())
{
MediaItem = umbContent
};
Expand All @@ -191,7 +193,8 @@ public void ExpectedOutputIfValidMedia()
null,
urlProvider.Object,
_settings,
null)
null,
Mock.Of<ILogger<InlineSvgTagHelper>>())
{
MediaItem = umbContent
};
Expand All @@ -212,7 +215,7 @@ public void SanitizesJavascript()
.Setup(p => p.GetFileInfo(It.IsAny<string>()))
.Returns(Mock.Of<IFileInfo>(f => f.Exists && f.CreateReadStream() == new MemoryStream(Encoding.UTF8.GetBytes("<a xlink:href=\"javascript:alert('test');\">Click here</a><script attr=\"test\">test</script>end"))));
var hostEnv = Mock.Of<IWebHostEnvironment>(e => e.WebRootFileProvider == fileProvider.Object);
var tagHelper = new InlineSvgTagHelper(null, hostEnv, null, _settings, null)
var tagHelper = new InlineSvgTagHelper(null, hostEnv, null, _settings, null, Mock.Of<ILogger<InlineSvgTagHelper>>())
{
FileSource = "test.svg"
};
Expand Down

0 comments on commit 3a547d7

Please sign in to comment.