public void DefaultViewComponentActivator_ActivatesViewComponentContext_IgnoresNonPublic() { // Arrange var expectedInstance = new VisibilityViewComponent(); var typeActivator = new Mock <ITypeActivatorCache>(); typeActivator .Setup(ta => ta.CreateInstance <object>(It.IsAny <IServiceProvider>(), It.IsAny <Type>())) .Returns(expectedInstance); var activator = new DefaultViewComponentActivator(typeActivator.Object); var context = CreateContext(typeof(VisibilityViewComponent)); expectedInstance.ViewComponentContext = context; // Act var instance = activator.Create(context) as VisibilityViewComponent; // Assert Assert.NotNull(instance); Assert.Same(context, instance.ViewComponentContext); Assert.Null(instance.C); }
public async Task DefaultViewComponentActivator_ReleaseAsync_PrefersAsyncDisposableOverDisposable() { // Arrange var instance = new SyncAndAsyncDisposableViewComponent(); var activator = new DefaultViewComponentActivator(Mock.Of <ITypeActivatorCache>()); var context = CreateContext(typeof(SyncAndAsyncDisposableViewComponent)); // Act await activator.ReleaseAsync(context, instance); // Assert Assert.True(instance.AsyncDisposed); Assert.False(instance.SyncDisposed); }