Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy #27

Merged
merged 10 commits into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Kontent.Statiq.Tests/Kontent.Statiq.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="Statiq.Core" Version="1.0.0-beta.24" />
<PackageReference Include="Statiq.Razor" Version="1.0.0-beta.24" />
<PackageReference Include="Statiq.Testing" Version="1.0.0-beta.24" />
<PackageReference Include="Statiq.Core" Version="1.0.0-beta.31" />
<PackageReference Include="Statiq.Razor" Version="1.0.0-beta.31" />
<PackageReference Include="Statiq.Testing" Version="1.0.0-beta.31" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/AboutUs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class AboutUs
public const string SitemapCodename = "sitemap";
public const string UrlPatternCodename = "url_pattern";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<object> Facts { get; set; }
public string MetadataMetaDescription { get; set; }
public string MetadataMetaTitle { get; set; }
Expand All @@ -41,5 +42,6 @@ public partial class AboutUs
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string UrlPattern { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Accessory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public partial class Accessory
public const string SitemapCodename = "sitemap";
public const string UrlPatternCodename = "url_pattern";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<IAsset> Image { get; set; }
public IRichTextContent LongDescription { get; set; }
public string Manufacturer { get; set; }
Expand All @@ -53,5 +54,6 @@ public partial class Accessory
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string UrlPattern { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Article.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public partial class Article
public const string TitleCodename = "title";
public const string UrlPatternCodename = "url_pattern";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IRichTextContent BodyCopy { get; set; }
public string MetadataMetaDescription { get; set; }
public string MetadataMetaTitle { get; set; }
Expand All @@ -57,5 +58,6 @@ public partial class Article
public IEnumerable<IAsset> TeaserImage { get; set; }
public string Title { get; set; }
public string UrlPattern { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Brewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public partial class Brewer
public const string SitemapCodename = "sitemap";
public const string UrlPatternCodename = "url_pattern";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<IAsset> Image { get; set; }
public IRichTextContent LongDescription { get; set; }
public IEnumerable<ITaxonomyTerm> Manufacturer { get; set; }
Expand All @@ -53,5 +54,6 @@ public partial class Brewer
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string UrlPattern { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Cafe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class Cafe
public const string StreetCodename = "street";
public const string ZipCodeCodename = "zip_code";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public string City { get; set; }
public string Country { get; set; }
public string Email { get; set; }
Expand All @@ -33,5 +34,6 @@ public partial class Cafe
public string Street { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string ZipCode { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Coffee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public partial class Coffee
public const string UrlPatternCodename = "url_pattern";
public const string VarietyCodename = "variety";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public string Altitude { get; set; }
public string Country { get; set; }
public string Farm { get; set; }
Expand All @@ -61,5 +62,6 @@ public partial class Coffee
public IContentItemSystemAttributes System { get; set; }
public string UrlPattern { get; set; }
public string Variety { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
4 changes: 2 additions & 2 deletions Kontent.Statiq.Tests/Models/CustomTypeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public class CustomTypeProvider : ITypeProvider
{typeof(Tweet), "tweet"}
};

public Type GetType(string contentType)
public Type? GetType(string contentType)
{
return _codenames.Keys.FirstOrDefault(type => GetCodename(type).Equals(contentType));
}

public string GetCodename(Type contentType)
{
return _codenames.TryGetValue(contentType, out var codename) ? codename : null;
return _codenames.TryGetValue(contentType, out var codename) ? codename : "";
}
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/FactAboutUs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public partial class FactAboutUs
public const string SitemapCodename = "sitemap";
public const string TitleCodename = "title";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IRichTextContent Description { get; set; }
public IEnumerable<IAsset> Image { get; set; }
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string Title { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Grinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public partial class Grinder
public const string SitemapCodename = "sitemap";
public const string UrlPatternCodename = "url_pattern";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<IAsset> Image { get; set; }
public IRichTextContent LongDescription { get; set; }
public string Manufacturer { get; set; }
Expand All @@ -53,5 +54,6 @@ public partial class Grinder
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string UrlPattern { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/HeroUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public partial class HeroUnit
public const string SitemapCodename = "sitemap";
public const string TitleCodename = "title";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<IAsset> Image { get; set; }
public IRichTextContent MarketingMessage { get; set; }
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string Title { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class Home
public const string SitemapCodename = "sitemap";
public const string UrlPatternCodename = "url_pattern";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<object> Articles { get; set; }
public IEnumerable<object> Cafes { get; set; }
public IRichTextContent Contact { get; set; }
Expand All @@ -49,5 +50,6 @@ public partial class Home
public IEnumerable<ITaxonomyTerm> Sitemap { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string UrlPattern { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/HostedVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public partial class HostedVideo
public const string VideoHostCodename = "video_host";
public const string VideoIdCodename = "video_id";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IContentItemSystemAttributes System { get; set; }
public IEnumerable<IMultipleChoiceOption> VideoHost { get; set; }
public string VideoId { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Office.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class Office
public const string StreetCodename = "street";
public const string ZipCodeCodename = "zip_code";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public string City { get; set; }
public string Country { get; set; }
public string Email { get; set; }
Expand All @@ -33,5 +34,6 @@ public partial class Office
public string Street { get; set; }
public IContentItemSystemAttributes System { get; set; }
public string ZipCode { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
2 changes: 2 additions & 0 deletions Kontent.Statiq.Tests/Models/Tweet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public partial class Tweet
public const string ThemeCodename = "theme";
public const string TweetLinkCodename = "tweet_link";

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public IEnumerable<IMultipleChoiceOption> DisplayOptions { get; set; }
public IContentItemSystemAttributes System { get; set; }
public IEnumerable<IMultipleChoiceOption> Theme { get; set; }
public string TweetLink { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
}
10 changes: 10 additions & 0 deletions Kontent.Statiq.Tests/Tools/KontentSetupHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,15 @@ public static IDeliveryClient WithFakeContent<TContent>(this IDeliveryClient cli

return client;
}

public static IDeliveryClient WithFakeTaxonomy(this IDeliveryClient client, params ITaxonomyGroup[] taxonomies)
{
var response = A.Fake<IDeliveryTaxonomyListingResponse>();
A.CallTo(() => response.Taxonomies).Returns(taxonomies);
A.CallTo(() => client.GetTaxonomiesAsync(A<IEnumerable<IQueryParameter>>._))
.Returns(response);

return client;
}
}
}
13 changes: 7 additions & 6 deletions Kontent.Statiq.Tests/Tools/TestContentItemSystemAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ namespace Kontent.Statiq.Tests.Tools
/// </summary>
internal sealed class TestContentItemSystemAttributes : IContentItemSystemAttributes
{
public string Id { get; internal set; }
public string Name { get; internal set; }
public string Codename { get; internal set; }
public string Type { get; internal set; }
public IList<string> SitemapLocation { get; internal set; }
public string Id { get; internal set; } = "";
public string Name { get; internal set; } = "";
public string Codename { get; internal set; } = "";
public string Type { get; internal set; } = "";
public string Collection { get; } = "";
public IList<string> SitemapLocation { get; internal set; } = Array.Empty<string>();
public DateTime LastModified { get; internal set; }
public string Language { get; internal set; }
public string Language { get; internal set; } = "";
}
}
69 changes: 69 additions & 0 deletions Kontent.Statiq.Tests/Tools/XUnitLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Microsoft.Extensions.Logging;
using System;
using Xunit.Abstractions;

namespace Kontent.Statiq.Tests.Tools
{
public class XUnitLoggerFactory : ILoggerFactory
{
private readonly ITestOutputHelper _output;

public XUnitLoggerFactory(ITestOutputHelper output)
{
_output = output;
}
public void Dispose()
{
throw new NotImplementedException();
}

public ILogger CreateLogger(string categoryName)
{
return new XunitLogger(_output, categoryName);
}

public void AddProvider(ILoggerProvider provider)
{

}
}
public class XunitLogger : ILogger
{
private readonly ITestOutputHelper _testOutputHelper;
private readonly string _categoryName;

public XunitLogger(ITestOutputHelper testOutputHelper, string categoryName)
{
_testOutputHelper = testOutputHelper;
_categoryName = categoryName;
}

public IDisposable BeginScope<TState>(TState state)
{
return NoopDisposable.Instance;
}

public bool IsEnabled(LogLevel logLevel)
{
return true;
}

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
_testOutputHelper.WriteLine($"{_categoryName} [{eventId}] {formatter(state, exception)}");

if (exception != null)
_testOutputHelper.WriteLine(exception.ToString());
}

private class NoopDisposable : IDisposable
{
public static NoopDisposable Instance = new NoopDisposable();

public void Dispose()
{

}
}
}
}
2 changes: 1 addition & 1 deletion Kontent.Statiq.Tests/When_executing_a_Statiq_pipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task It_should_correctly_set_the_default_content_from_richtext()
var deliveryClient = A.Fake<IDeliveryClient>().WithFakeContent(content);

var sut = new Kontent<Article>(deliveryClient)
.WithContent(item => item.BodyCopy.ToString() );
.WithContent(item => item.BodyCopy.ToString() ?? "" );

// Act
var engine = SetupExecution(sut,
Expand Down
8 changes: 0 additions & 8 deletions Kontent.Statiq.Tests/When_rendering_a_Razor_view.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Kontent.Statiq.Tests
{
public class When_rendering_a_Razor_view
{
private readonly ITestOutputHelper _testOutput;

public When_rendering_a_Razor_view(ITestOutputHelper testOutput)
{
_testOutput = testOutput;
}

[Fact]
public async Task It_should_pickup_Layout_and_view_start()
{
Expand Down
Loading