Exemple #1
0
        public async Task RenderRootComponentAsync_ReportsErrorDuringOnParameterSetAsync()
        {
            // Arrange
            var expected  = new TimeZoneNotFoundException();
            var renderer  = new TestRenderer();
            var component = new TestComponent {
                OnParametersSetAsyncLogic = _ => Task.FromException(expected)
            };

            // Act & Assert
            var componentId = renderer.AssignRootComponentId(component);
            var actual      = await Assert.ThrowsAsync <TimeZoneNotFoundException>(() => renderer.RenderRootComponentAsync(componentId));

            // Assert
            Assert.Same(expected, actual);
        }
Exemple #2
0
        public async Task Virtualize_ThrowsWhenGivenMultipleItemSources()
        {
            var rootComponent = new VirtualizeTestHostcomponent
            {
                InnerContent = BuildVirtualize(10f, EmptyItemsProvider <int>, new List <int>())
            };

            var serviceProvider = new ServiceCollection()
                                  .AddTransient((sp) => Mock.Of <IJSRuntime>())
                                  .BuildServiceProvider();

            var testRenderer = new TestRenderer(serviceProvider);
            var componentId  = testRenderer.AssignRootComponentId(rootComponent);

            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await testRenderer.RenderRootComponentAsync(componentId));

            Assert.Contains("can only accept one item source from its parameters", ex.Message);
        }
Exemple #3
0
        public async Task Virtualize_ThrowsWhenGivenNoItemSources()
        {
            var rootComponent = new VirtualizeTestHostcomponent
            {
                InnerContent = BuildVirtualize <int>(10f, null, null)
            };

            var serviceProvider = new ServiceCollection()
                                  .AddTransient((sp) => Mock.Of <IJSRuntime>())
                                  .BuildServiceProvider();

            var testRenderer = new TestRenderer(serviceProvider);
            var componentId  = testRenderer.AssignRootComponentId(rootComponent);

            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await testRenderer.RenderRootComponentAsync(componentId));

            Assert.Contains("parameters to be specified and non-null", ex.Message);
        }
Exemple #4
0
        public async Task Virtualize_ThrowsWhenGivenNonPositiveItemSize()
        {
            var rootComponent = new VirtualizeTestHostcomponent
            {
                InnerContent = BuildVirtualize(0f, EmptyItemsProvider <int>, null)
            };

            var serviceProvider = new ServiceCollection()
                                  .AddTransient((sp) => Mock.Of <IJSRuntime>())
                                  .BuildServiceProvider();

            var testRenderer = new TestRenderer(serviceProvider);
            var componentId  = testRenderer.AssignRootComponentId(rootComponent);

            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await testRenderer.RenderRootComponentAsync(componentId));

            Assert.Contains("requires a positive value for parameter", ex.Message);
        }