Ejemplo n.º 1
0
        public void BlazorEssentialsAuthorizationMessageHandler_LoadsCorrectUrls2()
        {
            var config = new SampleAdminConfigurationBase
            {
                ApiRoot = "https://test1",
                AppRoot = "https://test2"
            };
            var state = new BlazorEssentialsAuthorizationMessageHandler <SampleAdminConfigurationBase>(config, null, null);

            state.Should().NotBeNull();

            var privateObject = new PrivateObject(state, new PrivateType(typeof(AuthorizationMessageHandler)));
            var uris          = privateObject.GetField("_authorizedUris") as Uri[];

            uris.Should().NotBeNull().And.HaveCount(3);
        }
        public void BlazorEssentialsAuthorizationMessageHandler_LoadsCorrectUrls2()
        {
            var services = new ServiceCollection();
            var config   = new SampleAdminConfigurationBase
            {
                ApiRoot = "https://test1",
                AppRoot = "https://test2"
            };

            services.AddSingleton(config);
            services.AddHttpClients <SampleAdminConfigurationBase, BlazorEssentialsAuthorizationMessageHandler <SampleAdminConfigurationBase> >(config, HttpHandlerMode.None);

            var provider = services.BuildServiceProvider();

            var factory = provider.GetService <IHttpClientFactory>();

            factory.Should().NotBeNull();

            var client1 = factory.CreateClient(config.AdminApiClientName);

            client1.Should().NotBeNull();
            client1.BaseAddress.Should().Be(config.AdminApiRoot);
        }