Skip to content

Commit

Permalink
Merge pull request #1 from contentstack/develop
Browse files Browse the repository at this point in the history
API implementation for Sync and Content Type information.
  • Loading branch information
uttamukkoji authored Apr 12, 2019
2 parents bf5d631 + 4cef53c commit 5c9e192
Show file tree
Hide file tree
Showing 35 changed files with 1,461 additions and 350 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ packages/
*.config
*.nupkg
*.nuspec
Contentstack.core/docfx_project/*
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Version: 1.1.0
#### Date: Apr-12-2019

##### New Features:
- ContentstackClient
- added method 'GetContentTypes'
- added method 'SyncRecursive'
- added method 'SyncRecursiveLanguage'
- added method 'SyncPaginationToken'
- added method 'SyncToken'

- CotentType
- added method 'Fetch'

### Version: 1.0.6
#### Date: Apr-12-2019

Localization support for Query and Entry is added.

### Version: 1.0.0
#### Date: Apr-12-2019

- Introduce ContentStack SDK for DOTNET.
6 changes: 5 additions & 1 deletion Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
<PackageId>contentstack.aspnetcore</PackageId>
<Authors>Contentstack</Authors>
<Owners>Contentstack</Owners>
<ReleaseVersion>0.0.1</ReleaseVersion>
<ReleaseVersion>1.1.0</ReleaseVersion>
<PackageVersion>1.0.0</PackageVersion>
<Description>Main release</Description>
<Copyright>Copyright (c) 2012-2019 Contentstack (http://app.contentstack.com). All Rights Reserved
</Copyright>
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
<PackageTags>v1.0.0</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
50 changes: 50 additions & 0 deletions Contentstack.Core.Tests/ContentTypeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using Xunit;
using Contentstack.Core.Models;
using System.Threading.Tasks;
using Contentstack.Core.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections;

namespace Contentstack.Core.Tests
{
public class ContentTypeTest

{
ContentstackClient client = StackConfig.GetStack();
String source = "source";

[Fact]
public async Task FetchContenTypeSchema()
{
ContentType contenttype = client.ContentType(source);
var result = await contenttype.Fetch();
if (result == null)
{
Assert.False(true, "contenttype.FetchSchema() is not match with expected result.");
}
else
{
Assert.True(true);
}
}

[Fact]
public async Task GetContentTypes()
{
var result = await client.GetContentTypes();

if (result == null)
{
Assert.False(true, "client.getContentTypes is not match with expected result.");
}
else
{
Assert.True(true);

}
}
}
}
4 changes: 3 additions & 1 deletion Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>0.0.1</ReleaseVersion>
<ReleaseVersion>1.1.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -33,6 +34,7 @@
<None Remove="TestResults\Prod_2018-09-30_13_16_23.trx" />
<None Remove="TestResults\_Uttams-MacBook-Pro_2018-09-29_00_07_58.trx" />
<None Remove="TestResults\_Uttams-MacBook-Pro_2018-09-29_19_54_44.trx" />
<None Remove="appSetting.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ContentStack.Core\Contentstack.Core.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions Contentstack.Core.Tests/EntryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using System.Collections;

namespace Contentstack.Core.Tests
{

Expand All @@ -15,7 +16,6 @@ public class EntryTest
ContentstackClient client = StackConfig.GetStack();


String numbersContentType = "numbers_content_type";
String source = "source";
String singelEntryFetchUID = "blt1f94e478501bba46";
String referenceFieldUID = "reference";
Expand Down
33 changes: 29 additions & 4 deletions Contentstack.Core.Tests/StackConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Contentstack.Core;
using Contentstack.Core.Models;
using System.Configuration;
using Microsoft.Extensions.Options;

namespace Contentstack.Core.Tests
{
Expand All @@ -17,6 +18,30 @@ System.Configuration.Configuration assemblyConfiguration
}
}

public static ContentstackClient GetSyncStack()
{
StackConfig config = new StackConfig();
if (config.assemblyConfiguration.HasFile && string.Compare(config.assemblyConfiguration.FilePath, config.currentConfiguration.FilePath, true) != 0)
{
config.assemblyConfiguration.SaveAs(config.currentConfiguration.FilePath);
ConfigurationManager.RefreshSection("appSettings");
ConfigurationManager.RefreshSection("connectionStrings");
}
string apiKey = ConfigurationManager.AppSettings["sync_api_key"];
string accessToken = ConfigurationManager.AppSettings["sync_access_token"];
string environment = ConfigurationManager.AppSettings["sync_environment"];
string host = ConfigurationManager.AppSettings["host"];
Configuration.ContentstackOptions contentstackOptions = new Configuration.ContentstackOptions
{
ApiKey = apiKey,
AccessToken = accessToken,
Environment = environment,
Host = host
};

ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper<Configuration.ContentstackOptions>(contentstackOptions));
return contentstackClient;
}

public static ContentstackClient GetStack()
{
Expand All @@ -30,16 +55,16 @@ public static ContentstackClient GetStack()
string apiKey = ConfigurationManager.AppSettings["api_key"];
string accessToken = ConfigurationManager.AppSettings["access_token"];
string environment = ConfigurationManager.AppSettings["environment"];

string host = ConfigurationManager.AppSettings["host"];
Configuration.ContentstackOptions contentstackOptions = new Configuration.ContentstackOptions
{
ApiKey = apiKey,
AccessToken = accessToken,
Environment = environment
Environment = environment,
Host = host
};

ContentstackClient contentstackClient = new ContentstackClient(apiKey, accessToken, environment);

ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper<Configuration.ContentstackOptions>(contentstackOptions));
return contentstackClient;

}
Expand Down
136 changes: 136 additions & 0 deletions Contentstack.Core.Tests/SyncStackTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
using System;
using Xunit;
using Contentstack.Core.Configuration;
using System.Threading.Tasks;

namespace Contentstack.Core.Tests
{
public class SyncStackTest
{
ContentstackClient client = StackConfig.GetSyncStack();

[Fact]
public async Task SyncInit()
{

var result = await client.SyncRecursive();

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}

[Fact]
public async Task SyncSyncType()
{

var result = await client.SyncRecursive(SyncType: Models.SyncType.asset_published);

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}
[Fact]
public async Task SyncContentType()
{

var result = await client.SyncRecursive(ContentTypeUid: "session");

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}
[Fact]
public async Task SyncStartFrom()
{

var result = await client.SyncRecursive(StartFrom:DateTime.Now);

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}
[Fact]
public async Task SyncTypeWithContentType()
{

var result = await client.SyncRecursive(SyncType: Models.SyncType.entry_published, ContentTypeUid: "session");

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}
[Fact]
public async Task SyncTypeWithStartFrom()
{

var result = await client.SyncRecursive(SyncType: Models.SyncType.entry_published, StartFrom:DateTime.Now);

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}

[Fact]
public async Task SyncPaginationToken()
{

var result = await client.SyncPaginationToken("***REMOVED***");

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}

[Fact]
public async Task SyncToken()
{

var result = await client.SyncToken("***REMOVED***");

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}
}
}
9 changes: 9 additions & 0 deletions Contentstack.Core/Configuration/ContentstackOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,14 @@ public class ContentstackOptions
/// </summary>
public string Environment { get; set; }

/// <summary>
/// The Host used to set host url for the ContentStack API.
/// </summary>
public string Host { get; set; }

/// <summary>
/// The Version number for the ContentStack API.
/// </summary>
public string Version { get; set; }
}
}
12 changes: 9 additions & 3 deletions Contentstack.Core/Contentstack.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
<PackageId>contentstack.csharp</PackageId>
<Authors>Contentstack</Authors>
<Description>.NET SDK for the Contentstack Content Delivery API.</Description>
<PackageVersion>1.0.6</PackageVersion>
<PackageVersion>1.1.0</PackageVersion>
<Owners>Contentstack</Owners>
<PackageReleaseNotes>Localization support for Query and Entry is added.</PackageReleaseNotes>
<ReleaseVersion>0.0.1</ReleaseVersion>
<PackageReleaseNotes>Fetching Content-Type schema
Stack Sync implemented </PackageReleaseNotes>
<ReleaseVersion>1.1.0</ReleaseVersion>
<Copyright>Copyright © 2012-2019 Contentstack. All Rights Reserved
</Copyright>
<PackOnBuild>true</PackOnBuild>
<PackageTags>v1.1.0</PackageTags>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -40,6 +45,7 @@
<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" />
Expand Down
Loading

0 comments on commit 5c9e192

Please sign in to comment.