Ramón Tomás 7 years ago
parent
commit
bf34bff8dd
7 changed files with 45 additions and 36 deletions
  1. +22
    -13
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs
  2. +11
    -12
      test/Services/FunctionalTests/Services/Basket/BasketScenariosBase.cs
  3. +5
    -7
      test/Services/IntegrationTests/Services/Basket/BasketScenarioBase.cs
  4. +2
    -1
      test/Services/LoadTest/Basket.API/AddBasket.webtest
  5. +1
    -1
      test/Services/LoadTest/Basket.API/Checkout.webtest
  6. +2
    -1
      test/Services/LoadTest/Basket.API/DeleteBasket.webtest
  7. +2
    -1
      test/Services/LoadTest/Basket.API/GetBasket.webtest

+ 22
- 13
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs View File

@ -9,6 +9,7 @@ namespace eShopOnContainers.Core.Services.Basket
public class BasketService : IBasketService
{
private readonly IRequestProvider _requestProvider;
private const string ApiUrlBase = "api/v1/basket";
public BasketService(IRequestProvider requestProvider)
{
@ -16,12 +17,13 @@ namespace eShopOnContainers.Core.Services.Basket
}
public async Task<CustomerBasket> GetBasketAsync(string guidUser, string token)
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
builder.Path = guidUser;
{
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
{
Path = $"{ApiUrlBase}/{guidUser}"
};
string uri = builder.ToString();
var uri = builder.ToString();
CustomerBasket basket =
await _requestProvider.GetAsync<CustomerBasket>(uri, token);
@ -33,9 +35,12 @@ namespace eShopOnContainers.Core.Services.Basket
public async Task<CustomerBasket> UpdateBasketAsync(CustomerBasket customerBasket, string token)
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
{
Path = ApiUrlBase
};
string uri = builder.ToString();
var uri = builder.ToString();
var result = await _requestProvider.PostAsync(uri, customerBasket, token);
@ -44,20 +49,24 @@ namespace eShopOnContainers.Core.Services.Basket
public async Task CheckoutAsync(BasketCheckout basketCheckout, string token)
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint + "/checkout");
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
{
Path = $"{ApiUrlBase}/checkout"
};
string uri = builder.ToString();
var uri = builder.ToString();
await _requestProvider.PostAsync(uri, basketCheckout, token);
}
public async Task ClearBasketAsync(string guidUser, string token)
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
builder.Path = guidUser;
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
{
Path = $"{ApiUrlBase}/{guidUser}"
};
string uri = builder.ToString();
var uri = builder.ToString();
await _requestProvider.DeleteAsync(uri, token);
}


+ 11
- 12
test/Services/FunctionalTests/Services/Basket/BasketScenariosBase.cs View File

@ -1,14 +1,13 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace FunctionalTests.Services.Basket
namespace FunctionalTests.Services.Basket
{
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using System.IO;
public class BasketScenariosBase
{
private const string ApiUrlBase = "api/v1/basket";
public TestServer CreateServer()
{
var webHostBuilder = new WebHostBuilder();
@ -22,14 +21,14 @@ namespace FunctionalTests.Services.Basket
{
public static string GetBasketByCustomer(string customerId)
{
return $"/{customerId}";
return $"{ApiUrlBase}/{customerId}";
}
}
public static class Post
{
public static string CreateBasket = "/";
public static string Checkout = "/checkout";
public static string CreateBasket = $"{ApiUrlBase}/";
public static string Checkout = $"{ApiUrlBase}/checkout";
}
}
}
}

+ 5
- 7
test/Services/IntegrationTests/Services/Basket/BasketScenarioBase.cs View File

@ -1,15 +1,13 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.eShopOnContainers.Services.Basket.API;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace IntegrationTests.Services.Basket
{
public class BasketScenarioBase
{
private const string ApiUrlBase = "api/v1/basket";
public TestServer CreateServer()
{
var webHostBuilder = new WebHostBuilder();
@ -23,14 +21,14 @@ namespace IntegrationTests.Services.Basket
{
public static string GetBasket(int id)
{
return $"{id}";
return $"{ApiUrlBase}/{id}";
}
}
public static class Post
{
public static string Basket = "";
public static string CheckoutOrder = "checkout";
public static string Basket = $"{ApiUrlBase}/";
public static string CheckoutOrder = $"{ApiUrlBase}/checkout";
}
}
}

+ 2
- 1
test/Services/LoadTest/Basket.API/AddBasket.webtest View File

@ -65,7 +65,7 @@
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
</FormPostHttpBody>
</Request>
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/basket" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Headers>
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}} " />
<Header Name="Accept" Value="application/json" />
@ -80,6 +80,7 @@
<ContextParameter Name="IdentityApiServer" Value="http://" />
<ContextParameter Name="BasketApiServer" Value="http://" />
<ContextParameter Name="UserId" Value="" />
<ContextParameter Name="ApiVersion" Value="v1" />
</ContextParameters>
<ValidationRules>
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />


+ 1
- 1
test/Services/LoadTest/Basket.API/Checkout.webtest View File

@ -65,7 +65,7 @@
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
</FormPostHttpBody>
</Request>
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/checkout" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/checkout" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Headers>
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}}" />
<Header Name="Accept" Value="application/json" />


+ 2
- 1
test/Services/LoadTest/Basket.API/DeleteBasket.webtest View File

@ -65,7 +65,7 @@
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
</FormPostHttpBody>
</Request>
<Request Method="DELETE" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Request Method="DELETE" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Headers>
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}} " />
<Header Name="Accept" Value="application/json" />
@ -79,6 +79,7 @@
<ContextParameter Name="IdentityApiServer" Value="http://" />
<ContextParameter Name="BasketApiServer" Value="http://" />
<ContextParameter Name="UserId" Value="" />
<ContextParameter Name="ApiVersion" Value="v1" />
</ContextParameters>
<ValidationRules>
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />


+ 2
- 1
test/Services/LoadTest/Basket.API/GetBasket.webtest View File

@ -65,7 +65,7 @@
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
</FormPostHttpBody>
</Request>
<Request Method="GET" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Request Method="GET" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Headers>
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}} " />
<Header Name="Accept" Value="application/json" />
@ -79,6 +79,7 @@
<ContextParameter Name="IdentityApiServer" Value="http://" />
<ContextParameter Name="BasketApiServer" Value="http://" />
<ContextParameter Name="UserId" Value="" />
<ContextParameter Name="ApiVersion" Value="v1" />
</ContextParameters>
<ValidationRules>
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />


Loading…
Cancel
Save