Exemplo n.º 1
0
        public void IServiceCollectionExtensions_Return_IJobRegistrator()
        {
            IServiceCollection serviceCollection = new ServiceCollection();
            var result = IServiceCollectionExtensions.UseQuartzHostedService(serviceCollection, null);

            result.Should()
            .NotBeNull()
            .And.BeAssignableTo <IJobRegistrator>()
            .Subject.Services.Should().Equal(serviceCollection);
        }
Exemplo n.º 2
0
        public void IServiceCollectionExtensions_Register_HostedService()
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            IServiceCollectionExtensions.UseQuartzHostedService(serviceCollection, null);

            var testClass = serviceCollection.BuildServiceProvider().GetRequiredService <IHostedService>();

            testClass.Should()
            .NotBeNull()
            .And.BeOfType <SilkierQuartz.HostedService.QuartzHostedService>();
        }
Exemplo n.º 3
0
        public void IServiceCollectionExtensions_Register_ISchedulerFactory()
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            IServiceCollectionExtensions.UseQuartzHostedService(serviceCollection, null);

            var testClass = serviceCollection.BuildServiceProvider().GetRequiredService <ISchedulerFactory>();

            testClass.Should()
            .NotBeNull()
            .And.BeOfType <StdSchedulerFactory>();
        }
Exemplo n.º 4
0
        public void IServiceCollectionExtensions_Register_ISchedulerFactory_WithParams()
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            IServiceCollectionExtensions.UseQuartzHostedService(serviceCollection, options => { options.Add("quartz.threadPool.threadCount", "1"); });

            // TODO: ѕроверить что параметры передались в конструктор
            var testClass = serviceCollection.BuildServiceProvider().GetRequiredService <ISchedulerFactory>();

            testClass.Should()
            .NotBeNull()
            .And.BeOfType <StdSchedulerFactory>();
        }
        public void AddPostCommentServiceInitializesCorrectly()
        {
            SetupLocalEnvironmentVariables();

            var services = new ServiceCollection();

            services.AddOptions <ExecutionContextOptions>();
            services.PostConfigure <ExecutionContextOptions>(
                x => x.AppDirectory = Directory.GetCurrentDirectory());

            IServiceCollectionExtensions.AddPostCommentService(services);

            Assert.NotNull(services.BuildServiceProvider().GetService <IPostCommentService>());
        }
Exemplo n.º 6
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)

        .UseSerilog()
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder
            .UseKestrel(opts =>
            {
                var configuration = opts.ApplicationServices.GetService <IConfiguration>();
                var hostenv       = opts.ApplicationServices.GetService <IHostEnvironment>();
                opts.Listen(IPAddress.Loopback, 5000);
                opts.Listen(IPAddress.Loopback, 5001, listenOptions =>
                {
                    listenOptions.UseHttps(
                        new X509Certificate2(IServiceCollectionExtensions.GetCerfificate(hostenv)));
                });
            });
            webBuilder.UseStartup <Startup>();
        });
Exemplo n.º 7
0
        public void CreateManagementApi_CallsFactoryMethod()
        {
            // Arrange
            var mockClient = new Mock <IManagementApiClient>();

            var mockFactory = new Mock <IAuth0ClientFactory>();

            mockFactory
            .Setup(mock => mock.GetManagementApiClient())
            .Returns(mockClient.Object);

            var mockServiceProvider = new Mock <IServiceProvider>();

            mockServiceProvider
            .Setup(mock => mock.GetService(typeof(IAuth0ClientFactory)))
            .Returns(mockFactory.Object);

            // Act
            var client = IServiceCollectionExtensions.CreateManagementApi(mockServiceProvider.Object);

            // Assert
            Assert.IsNotNull(client);
            Assert.AreEqual(mockClient.Object, client);
        }
Exemplo n.º 8
0
        public void AddKubernetesClient_ThrowsOnNulls()
        {
            var ex = Assert.Throws <ArgumentNullException>(() => IServiceCollectionExtensions.AddKubernetesClient(null));

            Assert.Equal("serviceCollection", ex.ParamName);
        }
Exemplo n.º 9
0
        public void GetKubernetesApplicationOptions_ThrowsOnNull()
        {
            var ex = Assert.Throws <ArgumentNullException>(() => IServiceCollectionExtensions.GetKubernetesApplicationOptions(null));

            Assert.Equal("serviceCollection", ex.ParamName);
        }
Exemplo n.º 10
0
        public void AddKubernetesApplicationInstanceInfo_ThrowsOnNull()
        {
            var ex = Assert.Throws <ArgumentNullException>(() => IServiceCollectionExtensions.AddKubernetesApplicationInstanceInfo(null));

            Assert.Equal("serviceCollection", ex.ParamName);
        }
Exemplo n.º 11
0
 public static void AddDependencyInjectionCustom(this IServiceCollection services)
 {
     IServiceCollectionExtensions.RegisterServices(services);
 }