File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
test/MyTested.AspNetCore.Mvc.ViewComponents.Test Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11
11
using Microsoft . AspNetCore . Mvc . ViewComponents ;
12
12
using Microsoft . AspNetCore . Mvc . ViewFeatures ;
13
13
using Microsoft . Extensions . DependencyInjection ;
14
+ using MyTested . AspNetCore . Mvc . Internal . Contracts ;
14
15
using Setups ;
15
16
using Setups . Services ;
16
17
using Setups . ViewComponents ;
@@ -550,5 +551,23 @@ public void WithViewContextFuncShouldSetItToAccessor()
550
551
551
552
MyApplication . StartsFrom < DefaultStartup > ( ) ;
552
553
}
554
+
555
+ [ Fact ]
556
+ public void ViewComponentDescriptorCacheShouldWorkCorrectlyAndReturnDescriptor ( )
557
+ {
558
+ MyApplication . StartsFrom < DefaultStartup > ( ) ;
559
+
560
+ MyViewComponent < NormalComponent >
561
+ . InvokedWith ( c => c . Invoke ( ) )
562
+ . ShouldPassForThe < NormalComponent > ( vc =>
563
+ {
564
+ var cache = vc . HttpContext . RequestServices . GetService < IViewComponentDescriptorCache > ( ) ;
565
+ var viewComponentDescriptor = cache . GetViewComponentDescriptor ( vc . GetType ( ) . GetMethod ( "Invoke" ) ) ;
566
+
567
+ Assert . True ( viewComponentDescriptor . GetType ( ) == typeof ( ViewComponentDescriptor ) ) ;
568
+ } ) ;
569
+
570
+ MyApplication . StartsFrom < DefaultStartup > ( ) ;
571
+ }
553
572
}
554
573
}
You can’t perform that action at this time.
0 commit comments