Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    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);
    }