Skip to content

Commit

Permalink
Merge pull request #81 from commercetools/RequestBuilders-UnitTests
Browse files Browse the repository at this point in the history
Request builders Unit Tests
  • Loading branch information
MicheleRezk authored Aug 23, 2021
2 parents 6211b6f + 8f2a6a5 commit 5fc6a6f
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 16 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ jobs:
working-directory: ./commercetools.Sdk
- run: dotnet test --verbosity=normal Tests/commercetools.Api.Serialization.Tests --no-build -c Release
working-directory: ./commercetools.Sdk
- run: dotnet test --verbosity=normal Tests/commercetools.Api.Tests --no-build -c Release
- run: dotnet test --verbosity=normal Tests/commercetools.Sdk.Api.Tests --no-build -c Release
working-directory: ./commercetools.Sdk

- run: dotnet test --verbosity=normal Tests/commercetools.Sdk.ImportApi.Tests --no-build -c Release
working-directory: ./commercetools.Sdk
- run: dotnet test --verbosity=normal Tests/commercetools.Sdk.MLApi.Tests --no-build -c Release
working-directory: ./commercetools.Sdk
- run: dotnet test --verbosity=normal Tests/commercetools.Sdk.HistoryApi.Tests --no-build -c Release
working-directory: ./commercetools.Sdk

integrationtests:
name: Integration tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public async void CreateAndDelete()
Key = $"sink-{TestingUtility.RandomInt()}",
ResourceType = IImportResourceType.Customer
};
var importSink = await _client.WithImportApi().WithProjectKey(_projectKey)
var importSink = await _client.WithImportApi().WithProjectKeyValue(_projectKey)
.ImportSinks()
.Post(importSinkDraft)
.ExecuteAsync();

Assert.NotNull(importSink);

var deletedImportSink = await _client.WithImportApi().WithProjectKey(_projectKey)
var deletedImportSink = await _client.WithImportApi().WithProjectKeyValue(_projectKey)
.ImportSinks()
.WithImportSinkKeyValue(importSink.Key)
.Delete()
Expand Down
7 changes: 6 additions & 1 deletion commercetools.Sdk/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
SHELL := /bin/bash
PACKAGE_DIR ?= $(LIB_NAME)

generate_sdk:
generate_sdk: generate_sdk_main generate_sdk_test

generate_sdk_main:
rmf-codegen generate -o "commercetools.Sdk.$(LIB_NAME)/Generated" -t CSHARP_CLIENT -b "commercetools.$(LIB_NAME)" $(GEN_RAML_FILE)

generate_sdk_test:
rmf-codegen generate -o "Tests/commercetools.Sdk.$(LIB_NAME).Tests/Generated" -t CSHARP_TEST -b "commercetools.$(LIB_NAME).Tests" $(GEN_RAML_FILE)
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.ComponentModel.DataAnnotations;
using commercetools.Base.Client;
using commercetools.Sdk.Api;
using commercetools.Sdk.Api.Serialization;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace commercetools.Api.Tests
namespace commercetools.Sdk.Api.Tests
{
public class ClientsFactoryTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.IO;
using Xunit;
using commercetools.Api.Models.Projects;
using commercetools.Base.Serialization;
using commercetools.Sdk.Api;
using commercetools.Sdk.Api.Serialization;
using Microsoft.Extensions.DependencyInjection;

namespace commercetools.Api.Tests
namespace commercetools.Sdk.Api.Tests
{
public class ProjectTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using commercetools.Sdk.Api.Client;

namespace commercetools.Api.Tests.Client
{
public class RequestBuilderParentTests
{
protected static readonly ApiRoot ApiRoot = new ApiRoot(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
using commercetools.Api.Models.Categories;
using commercetools.Api.Models.Common;
using commercetools.Base.Client;
using commercetools.Base.Serialization;
using commercetools.Sdk.Api;
using commercetools.Sdk.Api.Extensions;
using commercetools.Sdk.Api.Serialization;
using Microsoft.Extensions.DependencyInjection;

namespace commercetools.Api.Tests
namespace commercetools.Sdk.Api.Tests
{
public class RequestBuilderTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
<ProjectReference Include="..\..\commercetools.Base.Serialization\commercetools.Base.Serialization.csproj" />
<ProjectReference Include="..\..\commercetools.Sdk.Api\commercetools.Sdk.Api.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Generated" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using commercetools.Sdk.HistoryApi.Client;

namespace commercetools.HistoryApi.Tests.Client
{
public class RequestBuilderParentTests
{
protected static readonly HistoryApiRoot ApiRoot = new HistoryApiRoot(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\commercetools.Base.Serialization\commercetools.Base.Serialization.csproj" />
<ProjectReference Include="..\..\commercetools.Sdk.HistoryApi\commercetools.Sdk.HistoryApi.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Generated" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using commercetools.Sdk.ImportApi.Client;

namespace commercetools.ImportApi.Tests.Client
{
public class RequestBuilderParentTests
{
protected static readonly ImportApiRoot ApiRoot = new ImportApiRoot(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\commercetools.Base.Serialization\commercetools.Base.Serialization.csproj" />
<ProjectReference Include="..\..\commercetools.Sdk.ImportApi\commercetools.Sdk.ImportApi.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Generated" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using commercetools.Sdk.MLApi.Client;

namespace commercetools.MLApi.Tests.Client
{
public class RequestBuilderParentTests
{
protected static readonly MLApiRoot ApiRoot = new MLApiRoot(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\commercetools.Base.Serialization\commercetools.Base.Serialization.csproj" />
<ProjectReference Include="..\..\commercetools.Sdk.MLApi\commercetools.Sdk.MLApi.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Generated" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public HistoryApiRoot(IClient apiHttpClient)
{
this.ApiHttpClient = apiHttpClient;
}
public ByProjectKeyRequestBuilder WithProjectKey(string projectKey)
public ByProjectKeyRequestBuilder WithProjectKeyValue(string projectKey)
{
return new ByProjectKeyRequestBuilder(ApiHttpClient, ApiHttpClient?.SerializerService, projectKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ImportApiRoot(IClient apiHttpClient)
{
this.ApiHttpClient = apiHttpClient;
}
public ByProjectKeyRequestBuilder WithProjectKey(string projectKey)
public ByProjectKeyRequestBuilder WithProjectKeyValue(string projectKey)
{
return new ByProjectKeyRequestBuilder(ApiHttpClient, ApiHttpClient?.SerializerService, projectKey);
}
Expand Down
23 changes: 22 additions & 1 deletion commercetools.Sdk/commercetools.Sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.BCTest",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Base.Abstractions", "commercetools.Base.Abstractions\commercetools.Base.Abstractions.csproj", "{CE136B1B-A0F1-47C2-8B6D-F8FB67EF1F86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Api.Tests", "Tests\commercetools.Api.Tests\commercetools.Api.Tests.csproj", "{44CA0C3D-17E0-4135-9E82-109A0BA9C7A8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.Api.Tests", "Tests\commercetools.Sdk.Api.Tests\commercetools.Sdk.Api.Tests.csproj", "{44CA0C3D-17E0-4135-9E82-109A0BA9C7A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.Api", "commercetools.Sdk.Api\commercetools.Sdk.Api.csproj", "{074F0445-76BB-4F84-8E7B-59A24E07961A}"
EndProject
Expand All @@ -38,6 +38,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Api.ConsoleAp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.HistoryApi", "commercetools.Sdk.HistoryApi\commercetools.Sdk.HistoryApi.csproj", "{E320B3FD-5A89-470F-B8B8-0C64CD31AACE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.MLApi.Tests", "Tests\commercetools.Sdk.MLApi.Tests\commercetools.Sdk.MLApi.Tests.csproj", "{85589ABD-3D3A-48FA-80AE-FD2FAE01761A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.HistoryApi.Tests", "Tests\commercetools.Sdk.HistoryApi.Tests\commercetools.Sdk.HistoryApi.Tests.csproj", "{B93DE3E7-F3A6-4FAF-8525-1B5BE692EF0B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commercetools.Sdk.ImportApi.Tests", "Tests\commercetools.Sdk.ImportApi.Tests\commercetools.Sdk.ImportApi.Tests.csproj", "{6128A16B-FE11-4C09-8B41-3DD311DE979B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -104,6 +110,18 @@ Global
{E320B3FD-5A89-470F-B8B8-0C64CD31AACE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E320B3FD-5A89-470F-B8B8-0C64CD31AACE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E320B3FD-5A89-470F-B8B8-0C64CD31AACE}.Release|Any CPU.Build.0 = Release|Any CPU
{85589ABD-3D3A-48FA-80AE-FD2FAE01761A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85589ABD-3D3A-48FA-80AE-FD2FAE01761A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85589ABD-3D3A-48FA-80AE-FD2FAE01761A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85589ABD-3D3A-48FA-80AE-FD2FAE01761A}.Release|Any CPU.Build.0 = Release|Any CPU
{B93DE3E7-F3A6-4FAF-8525-1B5BE692EF0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B93DE3E7-F3A6-4FAF-8525-1B5BE692EF0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B93DE3E7-F3A6-4FAF-8525-1B5BE692EF0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B93DE3E7-F3A6-4FAF-8525-1B5BE692EF0B}.Release|Any CPU.Build.0 = Release|Any CPU
{6128A16B-FE11-4C09-8B41-3DD311DE979B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6128A16B-FE11-4C09-8B41-3DD311DE979B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6128A16B-FE11-4C09-8B41-3DD311DE979B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6128A16B-FE11-4C09-8B41-3DD311DE979B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0BE26648-8480-4F6C-A353-76D03266B0C3} = {C1623B8A-8B14-4C27-AB57-7A2C76EEACC7}
Expand All @@ -113,5 +131,8 @@ Global
{44CA0C3D-17E0-4135-9E82-109A0BA9C7A8} = {D4A429AE-8B66-4936-B91F-7226BF78B82A}
{1CB0F695-158E-472C-A485-AE6BC13BC3C6} = {C1623B8A-8B14-4C27-AB57-7A2C76EEACC7}
{E943E000-7FE7-4C8E-8F9F-4D6835470F6F} = {344C365C-06DF-4615-82C6-44D07D77D092}
{85589ABD-3D3A-48FA-80AE-FD2FAE01761A} = {D4A429AE-8B66-4936-B91F-7226BF78B82A}
{B93DE3E7-F3A6-4FAF-8525-1B5BE692EF0B} = {D4A429AE-8B66-4936-B91F-7226BF78B82A}
{6128A16B-FE11-4C09-8B41-3DD311DE979B} = {D4A429AE-8B66-4936-B91F-7226BF78B82A}
EndGlobalSection
EndGlobal

0 comments on commit 5fc6a6f

Please sign in to comment.