public void CreateAsyncReleaser_CreatesDelegateThatDisposesDisposableTypes() { // Arrange var context = new PageContext(); var viewContext = new ViewContext(); var activator = new DefaultPageModelActivatorProvider(); var model = new DisposableModel(); // Act & Assert var disposer = activator.CreateAsyncReleaser(new CompiledPageActionDescriptor { ModelTypeInfo = model.GetType().GetTypeInfo() }); Assert.NotNull(disposer); disposer(context, model); // Assert Assert.True(model.Disposed); }
public void CreateReleaser_CreatesDelegateThatDisposesDisposableTypes() { // Arrange var context = new PageContext(); var activator = new DefaultPageModelActivatorProvider(); var actionDescriptor = new CompiledPageActionDescriptor { ModelTypeInfo = typeof(DisposableModel).GetTypeInfo(), }; var model = new DisposableModel(); // Act & Assert var releaser = activator.CreateReleaser(actionDescriptor); releaser(context, model); // Assert Assert.True(model.Disposed); }