public void CreateReportBuilderException() { var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient <ISearchReportBuilder <ISearchResultModel, ISearchReportModel> >(sp => throw new Exception()); var serviceProvider = serviceCollection.BuildServiceProvider(); var factory = new MicrosoftDependencyInjectionSearchServiceFactory(serviceProvider); Assert.Throws(typeof(SearchException), () => factory.CreateReportBuilder <ISearchResultModel, ISearchReportModel>()); }
public void CreateReportBuilderSucceed() { var serviceCollection = new ServiceCollection(); var expected1 = new Mock <ISearchReportBuilder <ISearchResultModel, ISearchReportModel> >(); serviceCollection.AddTransient(sp => expected1.Object); var serviceProvider = serviceCollection.BuildServiceProvider(); var factory = new MicrosoftDependencyInjectionSearchServiceFactory(serviceProvider); var result = factory.CreateReportBuilder <ISearchResultModel, ISearchReportModel>(); result.Should().Be(expected1.Object); }