/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Mvc/Mvc.ViewFeatures/test/ViewComponents/ViewComponentFeatureProviderTest.cs
74 строки
2 KB
Shreyas Jejurkar
chore : Remove unwanted `using` statement (#39176)
02 янв 2022, 17:39
Не верифицирован
02 янв 2022, 17:39
c85baf8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Reflection; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Mvc.ViewFeatures.ViewComponents.ViewComponentsFeatureTest; namespace Microsoft.AspNetCore.Mvc.ViewFeatures.ViewComponents { public class ViewComponentFeatureProviderTest { [Fact] public void GetDescriptor_DefaultConventions() { // Arrange var manager = new ApplicationPartManager(); manager.ApplicationParts.Add(new TestPart(typeof(ConventionsViewComponent))); manager.FeatureProviders.Add(new ViewComponentFeatureProvider()); var feature = new ViewComponentFeature(); // Act manager.PopulateFeature(feature); // Assert Assert.Equal(new[] { typeof(ConventionsViewComponent).GetTypeInfo() }, feature.ViewComponents.ToArray()); } [Fact] public void GetDescriptor_WithAttribute() { // Arrange var manager = new ApplicationPartManager(); manager.ApplicationParts.Add(new TestPart(typeof(AttributeViewComponent))); manager.FeatureProviders.Add(new ViewComponentFeatureProvider()); var feature = new ViewComponentFeature(); // Act manager.PopulateFeature(feature); // Assert Assert.Equal(new[] { typeof(AttributeViewComponent).GetTypeInfo() }, feature.ViewComponents.ToArray()); } private class TestPart : ApplicationPart, IApplicationPartTypeProvider { public TestPart(params Type[] types) { Types = types.Select(t => t.GetTypeInfo()); } public override string Name => "Test"; public IEnumerable<TypeInfo> Types { get; } } } } // These tests need to be public for the test to be valid namespace Microsoft.AspNetCore.Mvc.ViewFeatures.ViewComponents.ViewComponentsFeatureTest { public class ConventionsViewComponent { public string Invoke() => "Hello world"; } [ViewComponent(Name = "AttributesAreGreat")] public class AttributeViewComponent { public Task<string> InvokeAsync() => Task.FromResult("Hello world"); } }