Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ public class EditingScriptsTagHelper : TagHelper
/// <inheritdoc />
public override void Process(TagHelperContext context, TagHelperOutput output)
{
ISitecoreRenderingContext renderingContext = ViewContext?.HttpContext.GetSitecoreRenderingContext() ??
throw new NullReferenceException(Resources.Exception_EditingScriptsTagHelperSitecoreRenderingContextNull);
ISitecoreRenderingContext? renderingContext = ViewContext?.HttpContext.GetSitecoreRenderingContext();

output.TagName = string.Empty;
string html = string.Empty;

if (renderingContext.Response?.Content?.Sitecore?.Context?.IsEditing ?? false)
if (renderingContext?.Response?.Content?.Sitecore?.Context?.IsEditing ?? false)
{
EditingContext? editingContext = JsonSerializer.Deserialize<EditingContext>(renderingContext.Response?.Content.ContextRawData ?? string.Empty);
if (editingContext == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Ctor_InvalidArgs_Throws(GuardClauseAssertion guard)

[Theory]
[AutoNSubstituteData]
public async Task ProcessAsync_NoSitecoreContenxt_ExceptionIsThrown(EditingScriptsTagHelper sut, TagHelperContext tagHelperContext, TagHelperOutput tagHelperOutput)
public async Task ProcessAsync_NoSitecoreContext_EmptyResult(EditingScriptsTagHelper sut, TagHelperContext tagHelperContext, TagHelperOutput tagHelperOutput)
{
// Arrange
ViewContext viewContext = new()
Expand All @@ -66,10 +66,10 @@ public async Task ProcessAsync_NoSitecoreContenxt_ExceptionIsThrown(EditingScrip
sut.ViewContext = viewContext;

// Act
Func<Task> act = async () => await sut.ProcessAsync(tagHelperContext, tagHelperOutput);
await sut.ProcessAsync(tagHelperContext, tagHelperOutput);

// Assert
await act.Should().ThrowAsync<NullReferenceException>();
tagHelperOutput.Content.GetContent().Should().BeEmpty();
}

[Theory]
Expand Down
Loading