Skip to content

Commit

Permalink
Merge pull request #9 from contentstack/publish_fallback
Browse files Browse the repository at this point in the history
Publish fallback
  • Loading branch information
uttamukkoji authored Dec 5, 2020
2 parents 5103b58 + 5b3010f commit 411fcb4
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ packages/
*.nupkg
*.nuspec
*.trx
*/TestResults/
*/TestResults/
*/app.config
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### Version: 2.5.0
#### Date: Dec-05-2020

##### Update API:
- AssetLibrary
- IncludeFallback function added
- SetLocale function added
- Asset
- IncludeFallback function added
- SetLocale function added
- Entry
- IncludeFallback function added
- Query
- IncludeFallback function added

### Version: 2.4.0
#### Date: Aug-12-2020

Expand Down
9 changes: 6 additions & 3 deletions Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
<Authors>Contentstack</Authors>
<Owners>Contentstack</Owners>
<ReleaseVersion>2.1.1</ReleaseVersion>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>2.5.0</PackageVersion>
<Description>Main release</Description>
<Copyright>Copyright (c) 2012-2020 Contentstack (http://app.contentstack.com). All Rights Reserved</Copyright>
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
<PackageTags>v1.0.0</PackageTags>
<ReleaseVersion>2.4.0</ReleaseVersion>
<PackageTags>v2.5.0</PackageTags>
<ReleaseVersion>2.5.0</ReleaseVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType></DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="Contentstack.Core">
<HintPath>..\Contentstack.Core\bin\Debug\Contentstack.Core.dll</HintPath>
Expand Down
38 changes: 36 additions & 2 deletions Contentstack.Core.Tests/AssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,40 @@ await asset.Fetch().ContinueWith((t) =>
});
}

[Fact]
public async Task FetchAssetsPublishFallback()
{
List<string> list = new List<string>();
list.Add("en-us");
list.Add("ja-jp");
ContentstackCollection<Asset> assets = await client.AssetLibrary()
.SetLocale("ja-jp")
.IncludeFallback()
.FetchAll();
;
Assert.True(assets.Items.Count() > 0);
foreach (Asset asset in assets)
{
Assert.Contains((string)(asset.Get("publish_details") as JObject).GetValue("locale"), list);
}
}

[Fact]
public async Task FetchAssetsPublishWithoutFallback()
{
List<string> list = new List<string>();
list.Add("ja-jp");
ContentstackCollection<Asset> assets = await client.AssetLibrary()
.SetLocale("ja-jp")
.FetchAll();
;
Assert.True(assets.Items.Count() > 0);
foreach (Asset asset in assets)
{
Assert.Contains((string)(asset.Get("publish_details") as JObject).GetValue("locale"), list);
}
}

[Fact]
public async Task FetchAssets()
{
Expand Down Expand Up @@ -94,7 +128,7 @@ public async Task FetchAssetsIncludeRelativeURL()
[Fact]
public async Task FetchAssetCountAsync()
{
AssetLibrary assetLibrary = client.AssetLibrary();
AssetLibrary assetLibrary = client.AssetLibrary().SetLocale("en-us");
JObject jObject = await assetLibrary.Count();
if (jObject == null)
{
Expand All @@ -114,7 +148,7 @@ public async Task FetchAssetCountAsync()
[Fact]
public async Task FetchAssetSkipLimit()
{
AssetLibrary assetLibrary = client.AssetLibrary().Skip(2).Limit(5);
AssetLibrary assetLibrary = client.AssetLibrary().SetLocale("en-us").Skip(2).Limit(5);
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
if (assets == null)
{
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>2.4.0</ReleaseVersion>
<ReleaseVersion>2.5.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
34 changes: 34 additions & 0 deletions Contentstack.Core.Tests/QueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,40 @@ public async Task FetchAllGetContentType()
}
}

[Fact]
public async Task FetchEntriesPublishFallback()
{
List<string> list = new List<string>();
list.Add("en-us");
list.Add("ja-jp");
ContentstackCollection<Entry> entries = await client.ContentType(source).Query()
.SetLocale("ja-jp")
.IncludeFallback()
.Find<Entry>();
;
Assert.True(entries.Items.Count() > 0);
foreach (Entry entry in entries)
{
Assert.Contains((string)(entry.Get("publish_details") as JObject).GetValue("locale"), list);
}
}

[Fact]
public async Task FetchEntriesPublishWithoutFallback()
{
List<string> list = new List<string>();
list.Add("ja-jp");
ContentstackCollection<Entry> entries = await client.ContentType(source).Query()
.SetLocale("ja-jp")
.Find<Entry>();
;
Assert.True(entries.Items.Count() > 0);
foreach (Entry entry in entries)
{
Assert.Contains((string)(entry.Get("publish_details") as JObject).GetValue("locale"), list);
}
}

[Fact]
public async Task FetchAllCount()
{
Expand Down
28 changes: 6 additions & 22 deletions Contentstack.Core/Contentstack.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net47;net472;</TargetFrameworks>
<PackageId>contentstack.csharp</PackageId>
<Authors>Contentstack</Authors>
<Description>.NET SDK for the Contentstack Content Delivery API.</Description>
<PackageVersion>2.4.0</PackageVersion>
<PackageVersion>2.5.0</PackageVersion>
<Owners>Contentstack</Owners>
<PackageReleaseNotes>Entry model, JsonConverter added
Bug fixes Environment, Entry content types resolved</PackageReleaseNotes>
<PackageReleaseNotes>Publish content fallback </PackageReleaseNotes>
<Copyright>Copyright © 2012-2020 Contentstack. All Rights Reserved</Copyright>
<PackOnBuild>true</PackOnBuild>
<PackageTags>v2.4.0</PackageTags>
<PackageTags>v2.5.0</PackageTags>
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<ReleaseVersion>2.4.0</ReleaseVersion>
<ReleaseVersion>2.5.0</ReleaseVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -28,29 +27,14 @@ Bug fixes Environment, Entry content types resolved</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Markdig" Version="0.20.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.5" />
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.2.2"><PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Markdig" Version="0.22.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Internals\" />
<Folder Include="Models\" />
<Folder Include="Attributes\" />
</ItemGroup>
<ItemGroup>
<None Remove=".DS_Store" />
<None Remove="Contentstack.Core.nuspec" />
<None Remove="contentstack.csharp.1.0.0-alpha.nupkg" />
<None Remove="contentstack.csharp.1.0.1-alpha.nupkg" />
<None Remove="contentstack.csharp.1.0.2-alpha.nupkg" />
<None Remove="contentstack.csharp.1.0.3-alpha.nupkg" />
<None Remove="contentstack.csharp.1.0.4-alpha.nupkg" />
<None Remove="contentstack.csharp.1.0.5-alpha.nupkg" />
<None Remove="contentstack.csharp.1.0.6.nupkg" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ Global
$0.XmlFormattingPolicy = $9
$9.scope = application/xml
$0.StandardHeader = $10
version = 2.4.0
version = 2.5.0
EndGlobalSection
EndGlobal

0 comments on commit 411fcb4

Please sign in to comment.