-
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.
Adding Integration Testing for Get My ShoppingLists
- Loading branch information
1 parent
827fd79
commit 7f9ba91
Showing
3 changed files
with
118 additions
and
20 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
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 |
---|---|---|
|
@@ -5,13 +5,13 @@ | |
using commercetools.Base.Client.Error; | ||
using commercetools.Sdk.Api.Extensions; | ||
|
||
namespace commercetools.Api.IntegrationTests | ||
namespace commercetools.Api.IntegrationTests.Services | ||
{ | ||
public class CustomerServices | ||
{ | ||
public const string CUSTOMER_EMAIL = "[email protected]"; | ||
public const string CUSTOMER_PASSWORD = "password"; | ||
public const string CUSTOMER_KEY = "Customer_Me_Key123"; | ||
public const string CustomerEmail = "[email protected]"; | ||
public const string CustomerPassword = "password"; | ||
public const string CustomerKey = "Customer_Me_Key123"; | ||
public async Task<ICustomer> GetCustomerByKey(IClient adminClient,string key) | ||
{ | ||
try | ||
|
@@ -30,7 +30,7 @@ public async Task<ICustomer> GetCustomerByKey(IClient adminClient,string key) | |
|
||
return null; | ||
} | ||
public async Task<ICustomer> CreateCustomer(IClient adminClient,CustomerDraft customerDraft) | ||
public async Task<ICustomer> CreateCustomer(IClient adminClient,ICustomerDraft customerDraft) | ||
{ | ||
var customerSignInResult = await adminClient.WithApi().WithProjectKey(GenericFixture.DefaultProjectKey) | ||
.Customers() | ||
|
@@ -39,5 +39,17 @@ public async Task<ICustomer> CreateCustomer(IClient adminClient,CustomerDraft cu | |
var customer = customerSignInResult.Customer; | ||
return customer; | ||
} | ||
|
||
public ICustomerDraft CreateCustomerDraft() | ||
{ | ||
return new CustomerDraft | ||
{ | ||
Email = CustomerEmail, | ||
Password = CustomerPassword, | ||
Key = CustomerKey, | ||
FirstName = "FN_Me", | ||
LastName = "LN_Me" | ||
}; | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
....Sdk/IntegrationTests/commercetools.Api.IntegrationTests/Services/ShoppingListServices.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,56 @@ | ||
using System.Threading.Tasks; | ||
using commercetools.Api.Models.Common; | ||
using commercetools.Api.Models.Customers; | ||
using commercetools.Api.Models.ShoppingLists; | ||
using commercetools.Base.Client; | ||
using commercetools.Base.Client.Error; | ||
using commercetools.Sdk.Api.Extensions; | ||
|
||
namespace commercetools.Api.IntegrationTests.Services | ||
{ | ||
public class ShoppingListServices | ||
{ | ||
public const string ShoppingListKey = "ShoppingList_Me_Key123"; | ||
|
||
public async Task<IShoppingList> GetShoppingListByKey(IClient adminClient,string key) | ||
{ | ||
try | ||
{ | ||
var shoppingList = await adminClient.WithApi().WithProjectKey(GenericFixture.DefaultProjectKey) | ||
.ShoppingLists() | ||
.WithKey(key) | ||
.Get() | ||
.ExecuteAsync(); | ||
return shoppingList; | ||
} | ||
catch (NotFoundException) | ||
{ | ||
// ignored | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public async Task<IShoppingList> CreateShoppingList(IClient adminClient,IShoppingListDraft shoppingListDraft) | ||
{ | ||
var shoppingList = await adminClient.WithApi().WithProjectKey(GenericFixture.DefaultProjectKey) | ||
.ShoppingLists() | ||
.Post(shoppingListDraft) | ||
.ExecuteAsync(); | ||
return shoppingList; | ||
} | ||
|
||
public IShoppingListDraft CreateShoppingListDraft(ICustomerResourceIdentifier customerResourceIdentifier) | ||
{ | ||
return new ShoppingListDraft() | ||
{ | ||
Key = ShoppingListKey, | ||
Customer = customerResourceIdentifier, | ||
Name = new LocalizedString | ||
{ | ||
{"en", ShoppingListKey} | ||
} | ||
}; | ||
} | ||
} | ||
} |