You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Xunit;
|
|
|
|
namespace Study.XUnitTest
|
|
{
|
|
public class ConfigrationTest
|
|
{
|
|
[Fact]
|
|
public void Test1()
|
|
{
|
|
CustomProviderStudy sudyProvider=new CustomProviderStudy();
|
|
var customConfiguration= sudyProvider.BuildConfigurationFromInMemoryCollection();
|
|
|
|
Assert.Equal(Environment.UserName, customConfiguration["Profile:UserName"]);
|
|
Assert.Equal("love", customConfiguration["Profile:UserName"]);
|
|
|
|
Assert.Equal(400, customConfiguration.GetValue<int>("AppConfiguration:MainWindow:Height"));
|
|
Assert.Equal(600, customConfiguration.GetValue<int>("AppConfiguration:MainWindow:Width"));
|
|
Assert.Equal(0, customConfiguration.GetValue<int>("AppConfiguration:MainWindow:Top"));
|
|
Assert.Equal(0, customConfiguration.GetValue<int>("AppConfiguration:MainWindow:Left"));
|
|
Assert.Contains("localdb", customConfiguration.GetValue<string>("AppConfiguration:ConnectionString"));
|
|
}
|
|
|
|
[Fact]
|
|
public void AppJsonTest()
|
|
{
|
|
CustomProviderStudy sudyProvider = new CustomProviderStudy();
|
|
var appJsonConfiguration = sudyProvider.BuildProviderFromAppJson();
|
|
|
|
Assert.NotNull(appJsonConfiguration);
|
|
|
|
//Assert.True(appJsonConfiguration.GetSection("club") != null);
|
|
}
|
|
|
|
[Fact]
|
|
public void BuildJsonTest()
|
|
{
|
|
CustomProviderStudy customProvider=new CustomProviderStudy();
|
|
var cc = customProvider.BuildProviderFromJson();
|
|
var dd= cc.GetChildren();
|
|
|
|
Assert.NotNull(cc);
|
|
Assert.NotNull(dd);
|
|
}
|
|
}
|
|
}
|