Skip to content

Commit b3f1fa0

Browse files
committed
Remove redundant config
1 parent b41e264 commit b3f1fa0

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

LinkDotNet.Blog.UnitTests/Web/AppConfigurationFactoryTests.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public void ShouldMapFromAppConfiguration()
2222
{ "Introduction:ProfilePictureUrl", "anotherurl" },
2323
{ "Introduction:Description", "desc" },
2424
{ "BlogPostsPerPage", "5" },
25-
{ "IsAboutMeEnabled", "true" },
2625
{ "AboutMeProfileInformation:Name", "Steven" },
2726
{ "AboutMeProfileInformation:Heading", "Dev" },
2827
{ "AboutMeProfileInformation:ProfilePictureUrl", "Url" },
@@ -68,7 +67,6 @@ public void ShouldSetGithubLinkedAccountAccordingToValueSet(
6867
{ "GithubAccountUrl", githubUrl },
6968
{ "LinkedInAccountUrl", linkedInUrl },
7069
{ "BlogPostsPerPage", "2" },
71-
{ "IsAboutMeEnabled", "false" },
7270
};
7371
var configuration = new ConfigurationBuilder()
7472
.AddInMemoryCollection(inMemorySettings)
@@ -79,5 +77,24 @@ public void ShouldSetGithubLinkedAccountAccordingToValueSet(
7977
appConfiguration.HasGithubAccount.Should().Be(githubAvailable);
8078
appConfiguration.HasLinkedinAccount.Should().Be(linkedInAvailable);
8179
}
80+
81+
[Fact]
82+
public void ShouldSetIsAboutMeEnabledToFalseWhenNoInformation()
83+
{
84+
var inMemorySettings = new Dictionary<string, string>
85+
{
86+
{ "Introduction:BackgroundUrl", "someurl" },
87+
{ "Introduction:ProfilePictureUrl", "anotherurl" },
88+
{ "Introduction:Description", "desc" },
89+
{ "BlogPostsPerPage", "2" },
90+
};
91+
var configuration = new ConfigurationBuilder()
92+
.AddInMemoryCollection(inMemorySettings)
93+
.Build();
94+
95+
var appConfiguration = AppConfigurationFactory.Create(configuration);
96+
97+
appConfiguration.IsAboutMeEnabled.Should().BeFalse();
98+
}
8299
}
83100
}

LinkDotNet.Blog.Web/AppConfigurationFactory.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public static class AppConfigurationFactory
77
{
88
public static AppConfiguration Create(IConfiguration config)
99
{
10+
var profileInformation = config.GetSection("AboutMeProfileInformation").Get<ProfileInformation>();
1011
var configuration = new AppConfiguration
1112
{
1213
BlogName = config["BlogName"],
@@ -16,15 +17,10 @@ public static AppConfiguration Create(IConfiguration config)
1617
ConnectionString = config["ConnectionString"],
1718
DatabaseName = config["DatabaseName"],
1819
BlogPostsPerPage = int.Parse(config["BlogPostsPerPage"]),
19-
IsAboutMeEnabled = bool.Parse(config["IsAboutMeEnabled"]),
20+
ProfileInformation = profileInformation,
21+
IsAboutMeEnabled = profileInformation != null,
2022
};
2123

22-
if (configuration.IsAboutMeEnabled)
23-
{
24-
configuration.ProfileInformation =
25-
config.GetSection("AboutMeProfileInformation").Get<ProfileInformation>();
26-
}
27-
2824
return configuration;
2925
}
3026
}

LinkDotNet.Blog.Web/appsettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"ClientSecret": ""
2525
},
2626
"BlogPostsPerPage": 10,
27-
"IsAboutMeEnabled": true,
2827
"AboutMeProfileInformation": {
2928
"Name": "Steven Giesel",
3029
"Heading": "Software Engineer",

Readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ The appsettings.json file has a lot of options to customize the content of the b
3939
"ClientSecret": ""
4040
},
4141
"BlogPostsPerPage": 10,
42-
"IsAboutMeEnabled": true,
4342
"AboutMeProfileInformation": {
4443
"Name": "Steven Giesel",
4544
"Heading": "Software Engineer",
@@ -66,8 +65,7 @@ The appsettings.json file has a lot of options to customize the content of the b
6665
| ClientId | string | See more details here: https://manage.auth0.com/dashboard/ |
6766
| ClientSecret | string | See more details here: https://manage.auth0.com/dashboard/ |
6867
| BlogPostsPerPage | int | Gives the amount of blog posts loaded and display per page. For more the user has to use the navigation |
69-
| IsAboutMeEnabled | bool | If true, enalbes the "About Me" page |
70-
| AboutMeProfileInformation | node | If `IsAboutMeEnabled` is set to `false` this node can be left empty. |
68+
| AboutMeProfileInformation | node | Sets information for the About Me Page. If omitted the page is disabled completely |
7169
| Name | string | Name, which is displayed on top of the profile card |
7270
| Heading | string | Displayed under the name. For example job title |
7371
| ProfilePictureUrl | string | Displayed profile picture |

0 commit comments

Comments
 (0)