-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c52ab4d
commit b964fa3
Showing
11 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
using System.Runtime.CompilerServices; | ||
[assembly: InternalsVisibleTo("Opw.PineBlog.GitDb.Tests")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/Opw.PineBlog.GitDb.Tests/BlogSettingsConfigurationProviderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Xunit; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Opw.PineBlog.GitDb | ||
{ | ||
public class BlogSettingsConfigurationProviderTests : GitDbTestsBase | ||
{ | ||
private readonly IOptions<PineBlogGitDbOptions> _options; | ||
private readonly BlogSettingsConfigurationProvider _provider; | ||
|
||
public BlogSettingsConfigurationProviderTests(GitDbFixture fixture) : base(fixture) | ||
{ | ||
_options = ServiceProvider.GetRequiredService<IOptions<PineBlogGitDbOptions>>(); | ||
|
||
_provider = new BlogSettingsConfigurationProvider(new BlogSettingsConfigurationSource | ||
{ | ||
Options = _options.Value, | ||
ReloadOnChange = true | ||
}); | ||
} | ||
|
||
[Fact(Skip = Constants.SkipGitDbBlogSettingsConfigurationProviderTests)] | ||
public void Load_Should_HaveSettings() | ||
{ | ||
_provider.Load(); | ||
|
||
_provider.TryGet($"{nameof(PineBlogOptions)}:{nameof(PineBlogOptions.Title)}", out var title); | ||
_provider.TryGet($"{nameof(PineBlogOptions)}:{nameof(PineBlogOptions.Description)}", out var description); | ||
|
||
title.Should().Be("PineBlog"); | ||
description.Should().Be("A blogging engine based on ASP.NET Core MVC Razor Pages and Entity Framework Core"); | ||
} | ||
|
||
[Fact(Skip = Constants.SkipGitDbBlogSettingsConfigurationProviderTests)] | ||
public void Load_Should_NotHaveSettings() | ||
{ | ||
var options = _options.Value; | ||
options.RootPath = "invalid"; | ||
|
||
var provider = new BlogSettingsConfigurationProvider(new BlogSettingsConfigurationSource | ||
{ | ||
Options = _options.Value, | ||
ReloadOnChange = true | ||
}); | ||
|
||
provider.Load(); | ||
|
||
provider.TryGet($"{nameof(PineBlogOptions)}:{nameof(PineBlogOptions.Title)}", out var title); | ||
|
||
title.Should().BeNull(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
namespace Opw.PineBlog.GitDb | ||
{ | ||
public static class Constants | ||
{ | ||
public const string SkipGitDbBlogSettingsConfigurationProviderTests = null;//"These tests do not work on the build server."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Opw.PineBlog.GitDb | ||
{ | ||
public class PathHelperTests | ||
{ | ||
[Fact] | ||
public void Build_Should_ReturnPath() | ||
{ | ||
var result = PathHelper.Build("A", "B", "C"); | ||
|
||
result.Should().Be("A/B/C"); | ||
} | ||
|
||
[Fact] | ||
public void Build_Should_TrimSlashes() | ||
{ | ||
var result = PathHelper.Build("/A", "\\B", "C"); | ||
|
||
result.Should().Be("A/B/C"); | ||
} | ||
|
||
[Fact] | ||
public void Build_Should_IgnoreWhiteSpaceParts() | ||
{ | ||
var result = PathHelper.Build("A", " ", "", null, "B", "C"); | ||
|
||
result.Should().Be("A/B/C"); | ||
} | ||
} | ||
} |