Example #1
0
        public void AddReportConverter_WithHandler_HasHandler()
        {
            HtmlCellHandler cellHandler = new HtmlCellHandler();

            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddReportConverter <HtmlCell>(cellHandler)
                                              .BuildServiceProvider();

            IReportConverter <HtmlCell> converter = serviceProvider.GetService <IReportConverter <HtmlCell> >();

            converter.Should().NotBeNull()
            .And.BeOfType <ReportConverter <HtmlCell> >();
            ((ReportConverter <HtmlCell>)converter).Handlers.Should()
            .Equal(cellHandler);
        }
        public void AddReportConverter_ConverterWithHandlerAndName_HasHandler()
        {
            HtmlCellHandler cellHandler = new HtmlCellHandler();

            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddReportConverter <HtmlCell>("name", cellHandler)
                                              .BuildServiceProvider();

            IReportConverterFactory <HtmlCell> converterFactory =
                serviceProvider.GetService <IReportConverterFactory <HtmlCell> >();

            converterFactory.Should().NotBeNull();
            IReportConverter <HtmlCell> converter = converterFactory.Get("name");

            (converter as ReportConverter <HtmlCell>)?.Handlers.Should()
            .Equal(cellHandler);
        }
Example #3
0
        public void AddReportConverter_WithHandlerAndInterface_HasHandlerAndAllHandlersImplementingInterface()
        {
            HtmlCellHandler cellHandler = new HtmlCellHandler();

            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddReportConverter <HtmlCell, IHtmlPropertyHandler>(cellHandler)
                                              .BuildServiceProvider();

            IReportConverter <HtmlCell> converter = serviceProvider.GetService <IReportConverter <HtmlCell> >();

            converter.Should().NotBeNull()
            .And.BeOfType <ReportConverter <HtmlCell> >();
            ((ReportConverter <HtmlCell>)converter).Handlers.Should()
            .HaveCount(3)
            .And.Contain(h =>
                         h == cellHandler ||
                         h is IHtmlPropertyHandler);
        }
        public void AddReportConverter_ConverterWithHandlerAndInterfaceAndName_HasHandlerAndAllHandlersImplementingInterface()
        {
            HtmlCellHandler cellHandler = new HtmlCellHandler();

            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddReportConverter <HtmlCell, IHtmlPropertyHandler>("name", cellHandler)
                                              .BuildServiceProvider();

            IReportConverterFactory <HtmlCell> converterFactory =
                serviceProvider.GetService <IReportConverterFactory <HtmlCell> >();

            converterFactory.Should().NotBeNull();
            IReportConverter <HtmlCell> converter = converterFactory.Get("name");

            (converter as ReportConverter <HtmlCell>)?.Handlers.Should()
            .HaveCount(3)
            .And.Contain(h =>
                         h == cellHandler ||
                         h is IHtmlPropertyHandler);
        }