-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Auto Mation <[email protected]> Co-authored-by: Jens Schulze <[email protected]>
- Loading branch information
1 parent
dd77068
commit a617205
Showing
15 changed files
with
154 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/MultipleClientsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Linq; | ||
using commercetools.Api.IntegrationTests; | ||
using commercetools.Base.Client; | ||
using commercetools.Sdk.Api; | ||
using commercetools.Sdk.Api.Extensions; | ||
using commercetools.Sdk.ImportApi.Extensions; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
using ProjectApiRoot = commercetools.Sdk.Api.Client.ProjectApiRoot; | ||
using ImportProjectApiRoot = commercetools.Sdk.ImportApi.Client.ProjectApiRoot; | ||
|
||
namespace commercetools.Sdk.ImportApi.Tests | ||
{ | ||
public class MultipleClientsTest | ||
{ | ||
[Fact] | ||
public async void api_and_import() | ||
{ | ||
var configuration = new ConfigurationBuilder(). | ||
AddJsonFile("appsettings.test.Development.json", true). | ||
AddEnvironmentVariables(). | ||
AddUserSecrets<ServiceProviderFixture>(). | ||
AddEnvironmentVariables("CTP_"). | ||
Build(); | ||
|
||
var s = new ServiceCollection(); | ||
s.UseCommercetoolsImportApi(configuration, "Import"); | ||
s.UseCommercetoolsApi(configuration, "Client"); | ||
var p = s.BuildServiceProvider(); | ||
|
||
var apiConfig = configuration.GetSection("Client").Get<ClientConfiguration>(); | ||
var importApiRoot = p.GetService<ImportProjectApiRoot>(); | ||
var apiRoot = p.GetService<ProjectApiRoot>(); | ||
|
||
Assert.Equal("Import", importApiRoot.ClientName); | ||
Assert.Equal("Client", apiRoot.ClientName); | ||
var project = await apiRoot.Get().ExecuteAsync().ConfigureAwait(false); | ||
|
||
Assert.Equal(apiConfig.ProjectKey, project.Key); | ||
|
||
var importContainers = await importApiRoot.ImportContainers().Get().ExecuteAsync().ConfigureAwait(false); | ||
Assert.NotNull(importContainers); | ||
|
||
|
||
} | ||
|
||
[Fact] | ||
public async void api_and_import_create_root() | ||
{ | ||
var configuration = new ConfigurationBuilder(). | ||
AddJsonFile("appsettings.test.Development.json", true). | ||
AddEnvironmentVariables(). | ||
AddUserSecrets<ServiceProviderFixture>(). | ||
AddEnvironmentVariables("CTP_"). | ||
Build(); | ||
|
||
var s = new ServiceCollection(); | ||
s.UseCommercetoolsImportApi(configuration, "Import"); | ||
s.UseCommercetoolsApi(configuration, "Client"); | ||
var p = s.BuildServiceProvider(); | ||
|
||
var clients = p.GetServices<IClient>(); | ||
|
||
var importConfig = configuration.GetSection("Import").Get<ClientConfiguration>(); | ||
var apiConfig = configuration.GetSection("Client").Get<ClientConfiguration>(); | ||
|
||
var importApiRoot = clients.First(client => client.Name == "Import") | ||
.WithImportApi(importConfig.ProjectKey); | ||
var apiRoot = clients.First(client => client.Name == "Client") | ||
.WithProject(apiConfig.ProjectKey); | ||
|
||
Assert.Equal("Import", importApiRoot.ClientName); | ||
Assert.Equal("Client", apiRoot.ClientName); | ||
|
||
var project = await apiRoot.Get().ExecuteAsync().ConfigureAwait(false); | ||
|
||
Assert.Equal(apiConfig.ProjectKey, project.Key); | ||
|
||
var importContainers = await importApiRoot.ImportContainers().Get().ExecuteAsync().ConfigureAwait(false); | ||
Assert.NotNull(importContainers); | ||
|
||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...s.Sdk/commercetools.Sdk.Api/Generated/Models/Extensions/GoogleCloudFunctionDestination.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace commercetools.Sdk.Api.Models.Extensions | ||
{ | ||
|
||
public partial class GoogleCloudFunctionDestination : IGoogleCloudFunctionDestination | ||
{ | ||
public string Type { get; set; } | ||
|
||
public string Url { get; set; } | ||
public GoogleCloudFunctionDestination() | ||
{ | ||
this.Type = "GoogleCloudFunction"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
....Sdk/commercetools.Sdk.Api/Generated/Models/Extensions/IGoogleCloudFunctionDestination.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using commercetools.Base.CustomAttributes; | ||
|
||
|
||
namespace commercetools.Sdk.Api.Models.Extensions | ||
{ | ||
[DeserializeAs(typeof(commercetools.Sdk.Api.Models.Extensions.GoogleCloudFunctionDestination))] | ||
public partial interface IGoogleCloudFunctionDestination : IExtensionDestination | ||
{ | ||
string Url { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e0f48f22e6164e9ad9fba9047c7e33907757b0db |