public void AddReportConverter_WithCellType_CanBeRequested() { ServiceProvider serviceProvider = new ServiceCollection() .AddReportConverter <ReportCell>() .BuildServiceProvider(); IReportConverter <ReportCell> converter = serviceProvider.GetService <IReportConverter <ReportCell> >(); converter.Should().NotBeNull(); }
public void AddReportConverter_WithInterface_HasHandlersImplementingInterface() { ServiceProvider serviceProvider = new ServiceCollection() .AddReportConverter <HtmlCell, IHtmlPropertyHandler>() .BuildServiceProvider(); IReportConverter <HtmlCell> converter = serviceProvider.GetService <IReportConverter <HtmlCell> >(); converter.Should().NotBeNull() .And.BeOfType <ReportConverter <HtmlCell> >(); ((ReportConverter <HtmlCell>)converter).Handlers.Should() .HaveCount(2) .And.AllBeAssignableTo <IHtmlPropertyHandler>(); }
public void AddReportConverter_ConverterWithName_CanBeRequested() { ServiceProvider serviceProvider = new ServiceCollection() .AddReportConverter <HtmlCell>("name") .BuildServiceProvider(); IReportConverterFactory <HtmlCell> converterFactory = serviceProvider.GetService <IReportConverterFactory <HtmlCell> >(); converterFactory.Should().NotBeNull(); IReportConverter <HtmlCell> converter = converterFactory.Get("name"); converter.Should().NotBeNull(); }
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_ConverterWithNameRequestedTwice_ReturnsSameConverter() { const string name = "name"; ServiceProvider serviceProvider = new ServiceCollection() .AddReportConverter <HtmlCell>(name) .BuildServiceProvider(); IReportConverterFactory <HtmlCell> converterFactory = serviceProvider.GetService <IReportConverterFactory <HtmlCell> >(); IReportConverter <HtmlCell> firstConverter = converterFactory.Get(name); IReportConverter <HtmlCell> secondConverter = converterFactory.Get(name); firstConverter.Should().BeSameAs(secondConverter); }
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); }