Skip to content
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
22 changes: 22 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Unit Test
on:
pull_request:
push:

jobs:
unit-test:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v4.3.0
with:
dotnet-version: '7.0.x'
- name: Restore dependencies
run: dotnet restore Contentstack.Net.sln
- name: Build solution
run: dotnet build Contentstack.Net.sln --no-restore --configuration Debug
- name: Run unit tests
run: dotnet test Contentstack.Core.Unit.Tests/Contentstack.Core.Unit.Tests.csproj --no-build --verbosity normal --configuration Debug

20 changes: 10 additions & 10 deletions Contentstack.Core.Tests/AssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ await asset.Fetch().ContinueWith((t) =>
Asset result = t.Result;
if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
Assert.Fail( "Entry.Fetch is not match with expected result.");
}
else
{
Expand Down Expand Up @@ -116,7 +116,7 @@ public async Task FetchAssetsOrderByAscending()
{
if (dateTime.CompareTo(asset.GetCreateAt()) != -1 && dateTime.CompareTo(asset.GetCreateAt()) != 0)
{
Assert.False(true);
Assert.Fail();
}
}
dateTime = asset.GetCreateAt();
Expand Down Expand Up @@ -162,15 +162,15 @@ public async Task FetchAssetCountAsync()
JObject jObject = await assetLibrary.Count();
if (jObject == null)
{
Assert.False(true, "Query.Exec is not match with expected result.");
Assert.Fail( "Query.Exec is not match with expected result.");
}
else if (jObject != null)
{
Assert.Equal(5, jObject.GetValue("assets"));
}
else
{
Assert.False(true, "Result doesn't mathced the count.");
Assert.Fail( "Result doesn't mathced the count.");
}
}

Expand All @@ -181,15 +181,15 @@ public async Task FetchAssetSkipLimit()
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
if (assets == null)
{
Assert.False(true, "Query.Exec is not match with expected result.");
Assert.Fail( "Query.Exec is not match with expected result.");
}
else if (assets != null)
{
Assert.Equal(3, assets.Items.Count());
}
else
{
Assert.False(true, "Result doesn't mathced the count.");
Assert.Fail( "Result doesn't mathced the count.");
}
}

Expand All @@ -200,7 +200,7 @@ public async Task FetchAssetOnly()
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
if (assets == null)
{
Assert.False(true, "Query.Exec is not match with expected result.");
Assert.Fail( "Query.Exec is not match with expected result.");
}
else if (assets != null)
{
Expand All @@ -215,7 +215,7 @@ public async Task FetchAssetOnly()
}
else
{
Assert.False(true, "Result doesn't mathced the count.");
Assert.Fail( "Result doesn't mathced the count.");
}
}

Expand All @@ -226,7 +226,7 @@ public async Task FetchAssetExcept()
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();
if (assets == null)
{
Assert.False(true, "Query.Exec is not match with expected result.");
Assert.Fail( "Query.Exec is not match with expected result.");
}
else if (assets != null)
{
Expand All @@ -238,7 +238,7 @@ public async Task FetchAssetExcept()
}
else
{
Assert.False(true, "Result doesn't mathced the count.");
Assert.Fail( "Result doesn't mathced the count.");
}
}
[Fact]
Expand Down
8 changes: 4 additions & 4 deletions Contentstack.Core.Tests/ContentTypeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task FetchContenTypeSchema()
var result = await contenttype.Fetch();
if (result == null)
{
Assert.False(true, "contenttype.FetchSchema() is not match with expected result.");
Assert.Fail( "contenttype.FetchSchema() is not match with expected result.");
}
else
{
Expand All @@ -38,7 +38,7 @@ public async Task FetchContenTypeSchemaIncludeGlobalFields()
var result = await contenttype.Fetch(param);
if (result == null)
{
Assert.False(true, "contenttype.FetchSchema() is not match with expected result.");
Assert.Fail( "contenttype.FetchSchema() is not match with expected result.");
}
else
{
Expand All @@ -53,7 +53,7 @@ public async Task GetContentTypes()

if (result == null)
{
Assert.False(true, "client.getContentTypes is not match with expected result.");
Assert.Fail( "client.getContentTypes is not match with expected result.");
}
else
{
Expand All @@ -72,7 +72,7 @@ public async Task GetContentTypesIncludeGlobalFields()

if (result == null)
{
Assert.False(true, "client.getContentTypes is not match with expected result.");
Assert.Fail( "client.getContentTypes is not match with expected result.");
}
else
{
Expand Down
116 changes: 62 additions & 54 deletions Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,54 +1,62 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>$(Version)</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-reportgenerator-cli" Version="4.2.10" />
</ItemGroup>

<ItemGroup>
<Reference Include="Contentstack.Core">
<HintPath>..\Contentstack.Core\bin\Debug\Contentstack.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Remove="SingletoneTest.cs" />
<Compile Remove="EmptyClass.cs" />
<Compile Remove="appSetings.cs" />
<Compile Remove="TestResults\LocaleTest.cs" />
<Compile Remove="LocalTest.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="stack.config" />
<None Remove="Stack.config" />
<None Remove="TestResults\.DS_Store" />
<None Remove="TestResults\2018-09-29_19_56_27.trx" />
<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" />
<None Remove="appsetting.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contentstack.Core\Contentstack.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>$(Version)</ReleaseVersion>
<GenerateResourceFiles>false</GenerateResourceFiles>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Remove="**/*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-reportgenerator-cli" Version="4.2.10" />
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<PackageReference Include="Moq" Version="4.20.72" />
</ItemGroup>

<ItemGroup>
<Reference Include="Contentstack.Core">
<HintPath>..\Contentstack.Core\bin\Debug\Contentstack.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Remove="SingletoneTest.cs" />
<Compile Remove="EmptyClass.cs" />
<Compile Remove="appSetings.cs" />
<Compile Remove="TestResults\LocaleTest.cs" />
<Compile Remove="LocalTest.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="stack.config" />
<None Remove="Stack.config" />
<None Remove="TestResults\.DS_Store" />
<None Remove="TestResults\2018-09-29_19_56_27.trx" />
<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" />
<None Remove="appsetting.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contentstack.Core\Contentstack.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
</Project>
Loading
Loading