public void CreateReleaser_ReturnsNullForModelsThatDoNotImplementDisposable(Type pageType) { // Arrange var context = new PageContext(); var activator = new DefaultPageModelActivatorProvider(); var actionDescriptor = new CompiledPageActionDescriptor { PageTypeInfo = pageType.GetTypeInfo(), }; // Act var releaser = activator.CreateReleaser(actionDescriptor); // Assert Assert.Null(releaser); }
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); }