-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestOptions.cs
42 lines (37 loc) · 1.58 KB
/
TestOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Xunit;
namespace Meraki.Dashboard.Test
{
public class TestOptions
{
[Fact]
public void Options()
{
// Ensure this matches the appSettings.json file.
const string apiKey = "8A7H65KJ098MHGI09";
using (ServiceProvider serviceProvider = BuildServiceProvider())
{
MerakiDashboardClient merakiDashboardClient = serviceProvider.GetService<MerakiDashboardClient>();
Assert.Equal(apiKey, merakiDashboardClient.Client.ApiKey);
Assert.Equal(MerakiDashboardClientOptions.DefaultMerakiDashboardApiBaseAddress, merakiDashboardClient.Client.BaseAddress);
}
}
private static ServiceProvider BuildServiceProvider()
{
IConfigurationRoot configuration = new ConfigurationBuilder()
.AddJsonFile("appSettings.json")
.Build();
IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddOptions();
// Ensure the section matches the appSettings.json file
serviceCollection.Configure<MerakiDashboardClientOptions>(configuration.GetSection("merakiDashboard"));
serviceCollection.AddScoped<MerakiDashboardClient>();
return serviceCollection.BuildServiceProvider();
}
}
}