Skip to content

Commit 0dd1bf8

Browse files
committed
Make the tests pass
- Remove baseline tests. Those live with tooling - Unskip tests that should have been fixed years ago - Fix rendering test infrastructure
1 parent bdb5982 commit 0dd1bf8

27 files changed

+162
-4319
lines changed

src/Components/test/Microsoft.AspNetCore.Components.Build.Test/BindRazorIntegrationTest.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using Microsoft.AspNetCore.Components;
65
using Microsoft.AspNetCore.Components.Test.Helpers;
76
using Xunit;
7+
using Xunit.Abstractions;
88

99
namespace Microsoft.AspNetCore.Components.Build.Test
1010
{
1111
public class BindRazorIntegrationTest : RazorIntegrationTestBase
1212
{
13+
public BindRazorIntegrationTest(ITestOutputHelper output)
14+
: base(output)
15+
{
16+
}
17+
1318
internal override bool UseTwoPhaseCompilation => true;
1419

1520
[Fact]

src/Components/test/Microsoft.AspNetCore.Components.Build.Test/ChildContentRazorIntegrationTest.cs

Lines changed: 6 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System.Linq;
5-
using Microsoft.AspNetCore.Components.Razor;
6-
using Microsoft.AspNetCore.Components;
74
using Microsoft.AspNetCore.Components.RenderTree;
85
using Microsoft.AspNetCore.Components.Test.Helpers;
96
using Microsoft.CodeAnalysis.CSharp;
107
using Xunit;
8+
using Xunit.Abstractions;
119

1210
namespace Microsoft.AspNetCore.Components.Build.Test
1311
{
@@ -84,6 +82,11 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
8482
}
8583
");
8684

85+
public ChildContentRazorIntegrationTest(ITestOutputHelper output)
86+
: base(output)
87+
{
88+
}
89+
8790
internal override bool UseTwoPhaseCompilation => true;
8891

8992
[Fact]
@@ -410,174 +413,5 @@ public void Render_MultipleChildContent_ContextParameterOnComponent_SetsSameName
410413
frame => AssertFrame.Text(frame, " Content", 9),
411414
frame => AssertFrame.Text(frame, "Bye!", 11));
412415
}
413-
414-
[Fact]
415-
public void Render_ChildContent_AttributeAndBody_ProducesDiagnostic()
416-
{
417-
// Arrange
418-
AdditionalSyntaxTrees.Add(RenderChildContentComponent);
419-
420-
// Act
421-
var generated = CompileToCSharp(@"
422-
@addTagHelper *, TestAssembly
423-
@{ RenderFragment<string> template = @<div>@context.ToLowerInvariant()</div>; }
424-
<RenderChildContent ChildContent=""@template.WithValue(""HI"")"">
425-
Some Content
426-
</RenderChildContent>");
427-
428-
// Assert
429-
var diagnostic = Assert.Single(generated.Diagnostics);
430-
Assert.Same(BlazorDiagnosticFactory.ChildContentSetByAttributeAndBody.Id, diagnostic.Id);
431-
}
432-
433-
[Fact]
434-
public void Render_ChildContent_AttributeAndExplicitChildContent_ProducesDiagnostic()
435-
{
436-
// Arrange
437-
AdditionalSyntaxTrees.Add(RenderChildContentComponent);
438-
439-
// Act
440-
var generated = CompileToCSharp(@"
441-
@addTagHelper *, TestAssembly
442-
@{ RenderFragment<string> template = @<div>@context.ToLowerInvariant()</div>; }
443-
<RenderChildContent ChildContent=""@template.WithValue(""HI"")"">
444-
<ChildContent>
445-
Some Content
446-
</ChildContent>
447-
</RenderChildContent>");
448-
449-
// Assert
450-
var diagnostic = Assert.Single(generated.Diagnostics);
451-
Assert.Same(BlazorDiagnosticFactory.ChildContentSetByAttributeAndBody.Id, diagnostic.Id);
452-
}
453-
454-
[Fact]
455-
public void Render_ChildContent_ExplicitChildContent_UnrecogizedContent_ProducesDiagnostic()
456-
{
457-
// Arrange
458-
AdditionalSyntaxTrees.Add(RenderChildContentComponent);
459-
460-
// Act
461-
var generated = CompileToCSharp(@"
462-
@addTagHelper *, TestAssembly
463-
<RenderChildContent>
464-
<ChildContent>
465-
</ChildContent>
466-
@somethingElse
467-
</RenderChildContent>");
468-
469-
// Assert
470-
var diagnostic = Assert.Single(generated.Diagnostics);
471-
Assert.Same(BlazorDiagnosticFactory.ChildContentMixedWithExplicitChildContent.Id, diagnostic.Id);
472-
Assert.Equal(
473-
"Unrecognized child content inside component 'RenderChildContent'. The component 'RenderChildContent' accepts " +
474-
"child content through the following top-level items: 'ChildContent'.",
475-
diagnostic.GetMessage());
476-
}
477-
478-
[Fact]
479-
public void Render_ChildContent_ExplicitChildContent_UnrecogizedElement_ProducesDiagnostic()
480-
{
481-
// Arrange
482-
AdditionalSyntaxTrees.Add(RenderChildContentComponent);
483-
484-
// Act
485-
var generated = CompileToCSharp(@"
486-
@addTagHelper *, TestAssembly
487-
<RenderChildContent>
488-
<ChildContent>
489-
</ChildContent>
490-
<UnrecognizedChildContent></UnrecognizedChildContent>
491-
</RenderChildContent>");
492-
493-
// Assert
494-
var diagnostic = Assert.Single(generated.Diagnostics);
495-
Assert.Same(BlazorDiagnosticFactory.ChildContentMixedWithExplicitChildContent.Id, diagnostic.Id);
496-
}
497-
498-
[Fact]
499-
public void Render_ChildContent_ExplicitChildContent_UnrecogizedAttribute_ProducesDiagnostic()
500-
{
501-
// Arrange
502-
AdditionalSyntaxTrees.Add(RenderChildContentComponent);
503-
504-
// Act
505-
var generated = CompileToCSharp(@"
506-
@addTagHelper *, TestAssembly
507-
<RenderChildContent>
508-
<ChildContent attr>
509-
</ChildContent>
510-
</RenderChildContent>");
511-
512-
// Assert
513-
var diagnostic = Assert.Single(generated.Diagnostics);
514-
Assert.Same(BlazorDiagnosticFactory.ChildContentHasInvalidAttribute.Id, diagnostic.Id);
515-
}
516-
517-
[Fact]
518-
public void Render_ChildContent_ExplicitChildContent_InvalidParameterName_ProducesDiagnostic()
519-
{
520-
// Arrange
521-
AdditionalSyntaxTrees.Add(RenderChildContentStringComponent);
522-
523-
// Act
524-
var generated = CompileToCSharp(@"
525-
@addTagHelper *, TestAssembly
526-
<RenderChildContentString>
527-
<ChildContent Context=""@(""HI"")"">
528-
</ChildContent>
529-
</RenderChildContentString>");
530-
531-
// Assert
532-
var diagnostic = Assert.Single(generated.Diagnostics);
533-
Assert.Same(BlazorDiagnosticFactory.ChildContentHasInvalidParameter.Id, diagnostic.Id);
534-
}
535-
536-
[Fact]
537-
public void Render_ChildContent_ExplicitChildContent_RepeatedParameterName_GeneratesDiagnostic()
538-
{
539-
// Arrange
540-
AdditionalSyntaxTrees.Add(RenderChildContentStringComponent);
541-
542-
// Act
543-
var generated = CompileToCSharp(@"
544-
@addTagHelper *, TestAssembly
545-
<RenderChildContentString>
546-
<ChildContent>
547-
<RenderChildContentString>
548-
<ChildContent Context=""context"">
549-
</ChildContent>
550-
</RenderChildContentString>
551-
</ChildContent>
552-
</RenderChildContentString>");
553-
554-
// Assert
555-
var diagnostic = Assert.Single(generated.Diagnostics);
556-
Assert.Same(BlazorDiagnosticFactory.ChildContentRepeatedParameterName.Id, diagnostic.Id);
557-
Assert.Equal(
558-
"The child content element 'ChildContent' of component 'RenderChildContentString' uses the same parameter name ('context') as enclosing child content " +
559-
"element 'ChildContent' of component 'RenderChildContentString'. Specify the parameter name like: '<ChildContent Context=\"another_name\"> to resolve the ambiguity",
560-
diagnostic.GetMessage());
561-
}
562-
563-
[Fact]
564-
public void Render_ChildContent_ContextParameterNameOnComponent_Invalid_ProducesDiagnostic()
565-
{
566-
// Arrange
567-
AdditionalSyntaxTrees.Add(RenderChildContentStringComponent);
568-
569-
// Act
570-
var generated = CompileToCSharp(@"
571-
@addTagHelper *, TestAssembly
572-
<RenderChildContentString Context=""@Foo()"">
573-
</RenderChildContentString>");
574-
575-
// Assert
576-
var diagnostic = Assert.Single(generated.Diagnostics);
577-
Assert.Same(BlazorDiagnosticFactory.ChildContentHasInvalidParameterOnComponent.Id, diagnostic.Id);
578-
Assert.Equal(
579-
"Invalid parameter name. The parameter name attribute 'Context' on component 'RenderChildContentString' can only include literal text.",
580-
diagnostic.GetMessage());
581-
}
582416
}
583417
}

0 commit comments

Comments
 (0)