public async Task Virtualize_DispatchesExceptionsFromItemsProviderThroughRenderer() { Virtualize <int> renderedVirtualize = null; var rootComponent = new VirtualizeTestHostcomponent { InnerContent = BuildVirtualize(10f, AlwaysThrowsItemsProvider <int>, null, virtualize => renderedVirtualize = virtualize) }; var serviceProvider = new ServiceCollection() .AddTransient((sp) => Mock.Of <IJSRuntime>()) .BuildServiceProvider(); var testRenderer = new TestRenderer(serviceProvider); var componentId = testRenderer.AssignRootComponentId(rootComponent); // Render to populate the component reference. await testRenderer.RenderRootComponentAsync(componentId); Assert.NotNull(renderedVirtualize); // Simulate a JS spacer callback. ((IVirtualizeJsCallbacks)renderedVirtualize).OnAfterSpacerVisible(10f, 50f, 100f); // Validate that the exception is dispatched through the renderer. var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await testRenderer.RenderRootComponentAsync(componentId)); Assert.Equal("Thrown from items provider.", ex.Message); }
public async Task RefreshDataAsync() { if (Virtualize != null && Data != null) { await Virtualize.RefreshDataAsync(); } }