2017-06-08 17:33:55 +02:00
|
|
|
|
using Microsoft.eShopOnContainers.Services.Locations.API.Model;
|
|
|
|
|
using Microsoft.eShopOnContainers.Services.Locations.API.ViewModel;
|
2017-06-01 20:16:19 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace IntegrationTests.Services.Locations
|
|
|
|
|
{
|
|
|
|
|
public class LocationsScenarios
|
|
|
|
|
: LocationsScenarioBase
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
2017-06-08 17:33:55 +02:00
|
|
|
|
public async Task Set_new_user_seattle_location_response_ok_status_code()
|
2017-06-01 20:16:19 +02:00
|
|
|
|
{
|
|
|
|
|
using (var server = CreateServer())
|
|
|
|
|
{
|
2017-06-08 17:33:55 +02:00
|
|
|
|
var userId = 1234;
|
|
|
|
|
var content = new StringContent(BuildLocationsRequest(-122.315752, 47.604610), UTF8Encoding.UTF8, "application/json");
|
2017-06-01 20:16:19 +02:00
|
|
|
|
|
|
|
|
|
var response = await server.CreateClient()
|
|
|
|
|
.PostAsync(Post.AddNewLocation, content);
|
|
|
|
|
|
|
|
|
|
response.EnsureSuccessStatusCode();
|
2017-06-08 17:33:55 +02:00
|
|
|
|
|
|
|
|
|
var userLocationResponse = await server.CreateClient()
|
|
|
|
|
.GetAsync(Get.LocationBy(userId));
|
|
|
|
|
|
|
|
|
|
var responseBody = await userLocationResponse.Content.ReadAsStringAsync();
|
|
|
|
|
var userLocation = JsonConvert.DeserializeObject<UserLocation>(responseBody);
|
|
|
|
|
|
|
|
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
|
|
|
|
|
|
|
2017-06-01 20:16:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-08 17:33:55 +02:00
|
|
|
|
string BuildLocationsRequest(double lon, double lat)
|
2017-06-01 20:16:19 +02:00
|
|
|
|
{
|
|
|
|
|
var location = new LocationRequest()
|
|
|
|
|
{
|
2017-06-08 17:33:55 +02:00
|
|
|
|
Longitude = lon,
|
|
|
|
|
Latitude = lat
|
|
|
|
|
};
|
2017-06-01 20:16:19 +02:00
|
|
|
|
return JsonConvert.SerializeObject(location);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|