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 @@ -9,7 +9,7 @@
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X;

// This is just a basic integration test. There are detailed tests for the VCTH visitor and descriptor factory.
public class ViewComponentTagHelperDescriptorProviderTest
public class ViewComponentTagHelperProducerTest
{
[Fact]
public void DescriptorProvider_FindsVCTH()
Expand All @@ -24,12 +24,13 @@ public class StringParameterViewComponent

var compilation = MvcShim.BaseCompilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(code));

var context = new TagHelperDescriptorProviderContext(compilation);

var provider = new ViewComponentTagHelperDescriptorProvider()
var projectEngine = RazorProjectEngine.CreateEmpty(static b =>
{
Engine = RazorProjectEngine.CreateEmpty().Engine,
};
b.Features.Add(new ViewComponentTagHelperProducer.Factory());
b.Features.Add(new TagHelperDiscoveryService());
});

Assert.True(projectEngine.Engine.TryGetFeature(out ITagHelperDiscoveryService? service));

var expectedDescriptor = TagHelperDescriptorBuilder.CreateViewComponent("__Generated__StringParameterViewComponentTagHelper", TestCompilation.AssemblyName)
.TypeName("__Generated__StringParameterViewComponentTagHelper")
Expand All @@ -55,9 +56,9 @@ public class StringParameterViewComponent
.Build();

// Act
provider.Execute(context);
var result = service.GetTagHelpers(compilation);

// Assert
Assert.Single(context.Results, d => d.Equals(expectedDescriptor));
Assert.Single(result, d => d.Equals(expectedDescriptor));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X;

// This is just a basic integration test. There are detailed tests for the VCTH visitor and descriptor factory.
public class ViewComponentTagHelperDescriptorProviderTest
public class ViewComponentTagHelperProducerTest
{
[Fact]
public void DescriptorProvider_FindsVCTH()
Expand All @@ -24,12 +24,13 @@ public class StringParameterViewComponent

var compilation = MvcShim.BaseCompilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(code));

var context = new TagHelperDescriptorProviderContext(compilation);

var provider = new ViewComponentTagHelperDescriptorProvider()
var projectEngine = RazorProjectEngine.CreateEmpty(static b =>
{
Engine = RazorProjectEngine.CreateEmpty().Engine,
};
b.Features.Add(new ViewComponentTagHelperProducer.Factory());
b.Features.Add(new TagHelperDiscoveryService());
});

Assert.True(projectEngine.Engine.TryGetFeature(out ITagHelperDiscoveryService? service));

var expectedDescriptor = TagHelperDescriptorBuilder.CreateViewComponent("__Generated__StringParameterViewComponentTagHelper", TestCompilation.AssemblyName)
.TypeName("__Generated__StringParameterViewComponentTagHelper")
Expand All @@ -55,9 +56,9 @@ public class StringParameterViewComponent
.Build();

// Act
provider.Execute(context);
var result = service.GetTagHelpers(compilation);

// Assert
Assert.Single(context.Results, d => d.Equals(expectedDescriptor));
Assert.Single(result, d => d.Equals(expectedDescriptor));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions;

// This is just a basic integration test. There are detailed tests for the VCTH visitor and descriptor factory.
public class ViewComponentTagHelperDescriptorProviderTest
public class ViewComponentTagHelperProducerTest
{
[Fact]
public void DescriptorProvider_FindsVCTH()
Expand All @@ -24,12 +24,13 @@ public class StringParameterViewComponent

var compilation = TestCompilation.Create().AddSyntaxTrees(CSharpSyntaxTree.ParseText(code));

var context = new TagHelperDescriptorProviderContext(compilation);

var provider = new ViewComponentTagHelperDescriptorProvider()
var projectEngine = RazorProjectEngine.CreateEmpty(static b =>
{
Engine = RazorProjectEngine.CreateEmpty().Engine,
};
b.Features.Add(new ViewComponentTagHelperProducer.Factory());
b.Features.Add(new TagHelperDiscoveryService());
});

Assert.True(projectEngine.Engine.TryGetFeature(out ITagHelperDiscoveryService? service));

var expectedDescriptor = TagHelperDescriptorBuilder.CreateViewComponent("__Generated__StringParameterViewComponentTagHelper", TestCompilation.AssemblyName)
.TypeName("__Generated__StringParameterViewComponentTagHelper")
Expand All @@ -55,9 +56,9 @@ public class StringParameterViewComponent
.Build();

// Act
provider.Execute(context);
var result = service.GetTagHelpers(compilation);

// Assert
Assert.Single(context.Results, d => d.Equals(expectedDescriptor));
Assert.Single(result, d => d.Equals(expectedDescriptor));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private static void AssertDefaultFeatures(RazorProjectEngine engine)
feature => Assert.IsType<InheritsDirectivePass>(feature),
feature => Assert.IsType<MetadataAttributePass>(feature),
feature => Assert.IsType<PreallocatedTagHelperAttributeOptimizationPass>(feature),
feature => Assert.IsType<TagHelperDiscoveryService>(feature),
feature => Assert.IsType<ViewCssScopePass>(feature));
}

Expand Down
Loading