Esempio n. 1
0
        public void CreateReportProviderException()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <ISearchReportProvider <ISearchReportModel> >(sp => throw new Exception());
            var serviceProvider = serviceCollection.BuildServiceProvider();

            var factory = new MicrosoftDependencyInjectionSearchServiceFactory(serviceProvider);

            Assert.Throws(typeof(SearchException), () => factory.CreateReportProvider <ISearchReportModel>());
        }
Esempio n. 2
0
        public void CreateReportProviderSucceed()
        {
            var serviceCollection = new ServiceCollection();
            var reporter1         = new Mock <ISearchReportProvider <ISearchReportModel> >();
            var reporter2         = new Mock <ISearchReportProvider <ISearchReportModel> >();

            serviceCollection.AddTransient(sp => reporter1.Object);
            serviceCollection.AddTransient(sp => reporter2.Object);
            var serviceProvider = serviceCollection.BuildServiceProvider();

            var factory = new MicrosoftDependencyInjectionSearchServiceFactory(serviceProvider);
            var result  = factory.CreateReportProvider <ISearchReportModel>();

            CollectionAssert.AreEquivalent(new[] { reporter1.Object, reporter2.Object }, result);
        }