Migrate locations.functionaltest to 3.0
This commit is contained in:
parent
4d8f3cba65
commit
de36e8c09e
@ -18,10 +18,12 @@
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public double Latitude { get; set; }
|
public double Latitude { get; set; }
|
||||||
public double Longitude { get; set; }
|
public double Longitude { get; set; }
|
||||||
//public GeoJsonPoint<GeoJson2DGeographicCoordinates> Location { get; private set; }
|
|
||||||
public LocationPoint Location { get; private set; }
|
public LocationPoint Location { get; private set; }
|
||||||
public LocationPolygon Polygon { get; private set; }
|
public LocationPolygon Polygon { get; private set; }
|
||||||
//public GeoJsonPolygon<GeoJson2DGeographicCoordinates> Polygon { get; private set; }
|
|
||||||
|
// Temporal commented in previewVersion7 of netcore and 2.9.0-beta2 of Mongo packages, review in next versions
|
||||||
|
// public GeoJsonPoint<GeoJson2DGeographicCoordinates> Location { get; private set; }
|
||||||
|
// public GeoJsonPolygon<GeoJson2DGeographicCoordinates> Polygon { get; private set; }
|
||||||
public void SetLocation(double lon, double lat) => SetPosition(lon, lat);
|
public void SetLocation(double lon, double lat) => SetPosition(lon, lat);
|
||||||
public void SetArea(List<GeoJson2DGeographicCoordinates> coordinatesList) => SetPolygon(coordinatesList);
|
public void SetArea(List<GeoJson2DGeographicCoordinates> coordinatesList) => SetPolygon(coordinatesList);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
|
using Locations.API.Controllers;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
@ -37,17 +38,18 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
|||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
RegisterAppInsights(services);
|
RegisterAppInsights(services);
|
||||||
|
|
||||||
services.AddCustomHealthCheck(Configuration);
|
services.AddCustomHealthCheck(Configuration);
|
||||||
|
|
||||||
services.AddControllers(options =>
|
services.AddControllers(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||||
|
})
|
||||||
}).AddNewtonsoftJson();
|
.AddApplicationPart(typeof(LocationsController).Assembly)
|
||||||
|
.AddNewtonsoftJson();
|
||||||
|
|
||||||
ConfigureAuthService(services);
|
ConfigureAuthService(services);
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API;
|
using Microsoft.eShopOnContainers.Services.Locations.API;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -13,6 +17,13 @@ namespace Locations.FunctionalTests
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
// Added to avoid the Authorize data annotation in test environment.
|
||||||
|
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
|
||||||
|
services.Configure<RouteOptions>(Configuration);
|
||||||
|
return base.ConfigureServices(services);
|
||||||
|
}
|
||||||
protected override void ConfigureAuth(IApplicationBuilder app)
|
protected override void ConfigureAuth(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>$(NetCoreTargetVersion)</TargetFramework>
|
<TargetFramework>$(NetCoreTargetVersion)</TargetFramework>
|
||||||
|
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -12,37 +12,37 @@ namespace Locations.FunctionalTests
|
|||||||
public class LocationsScenarios
|
public class LocationsScenarios
|
||||||
: LocationsScenarioBase
|
: LocationsScenarioBase
|
||||||
{
|
{
|
||||||
//[Fact]
|
[Fact]
|
||||||
//public async Task Set_new_user_seattle_location_response_ok_status_code()
|
public async Task Set_new_user_seattle_location_response_ok_status_code()
|
||||||
//{
|
{
|
||||||
// using (var server = CreateServer())
|
using (var server = CreateServer())
|
||||||
// {
|
{
|
||||||
// var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed";
|
var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed";
|
||||||
// var content = new StringContent(BuildLocationsRequest(-122.315752, 47.604610), UTF8Encoding.UTF8, "application/json");
|
var content = new StringContent(BuildLocationsRequest(-122.315752, 47.604610), UTF8Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
// // Expected result
|
// Expected result
|
||||||
// var expectedLocation = "SEAT";
|
var expectedLocation = "SEAT";
|
||||||
|
|
||||||
// // Act
|
// Act
|
||||||
// var response = await server.CreateClient()
|
var response = await server.CreateClient()
|
||||||
// .PostAsync(Post.AddNewLocation, content);
|
.PostAsync(Post.AddNewLocation, content);
|
||||||
|
|
||||||
// var userLocationResponse = await server.CreateClient()
|
var userLocationResponse = await server.CreateClient()
|
||||||
// .GetAsync(Get.UserLocationBy(userId));
|
.GetAsync(Get.UserLocationBy(userId));
|
||||||
|
|
||||||
// var responseBody = await userLocationResponse.Content.ReadAsStringAsync();
|
var responseBody = await userLocationResponse.Content.ReadAsStringAsync();
|
||||||
// var userLocation = JsonConvert.DeserializeObject<UserLocation>(responseBody);
|
var userLocation = JsonConvert.DeserializeObject<UserLocation>(responseBody);
|
||||||
|
|
||||||
// var locationResponse = await server.CreateClient()
|
var locationResponse = await server.CreateClient()
|
||||||
// .GetAsync(Get.LocationBy(userLocation.LocationId));
|
.GetAsync(Get.LocationBy(userLocation.LocationId));
|
||||||
|
|
||||||
// responseBody = await locationResponse.Content.ReadAsStringAsync();
|
responseBody = await locationResponse.Content.ReadAsStringAsync();
|
||||||
// var location = JsonConvert.DeserializeObject<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>(responseBody);
|
var location = JsonConvert.DeserializeObject<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>(responseBody);
|
||||||
|
|
||||||
// // Assert
|
// Assert
|
||||||
// Assert.Equal(expectedLocation, location.Code);
|
Assert.Equal(expectedLocation, location.Code);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Set_new_user_readmond_location_response_ok_status_code()
|
public async Task Set_new_user_readmond_location_response_ok_status_code()
|
||||||
@ -79,53 +79,53 @@ namespace Locations.FunctionalTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Fact]
|
[Fact]
|
||||||
//public async Task Set_new_user_Washington_location_response_ok_status_code()
|
public async Task Set_new_user_Washington_location_response_ok_status_code()
|
||||||
//{
|
{
|
||||||
// using (var server = CreateServer())
|
using (var server = CreateServer())
|
||||||
// {
|
{
|
||||||
// var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed";
|
var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed";
|
||||||
// var content = new StringContent(BuildLocationsRequest(-121.040360, 48.091631), UTF8Encoding.UTF8, "application/json");
|
var content = new StringContent(BuildLocationsRequest(-121.040360, 48.091631), UTF8Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
// // Expected result
|
// Expected result
|
||||||
// var expectedLocation = "WHT";
|
var expectedLocation = "WHT";
|
||||||
|
|
||||||
// // Act
|
// Act
|
||||||
// var response = await server.CreateClient()
|
var response = await server.CreateClient()
|
||||||
// .PostAsync(Post.AddNewLocation, content);
|
.PostAsync(Post.AddNewLocation, content);
|
||||||
|
|
||||||
// var userLocationResponse = await server.CreateClient()
|
var userLocationResponse = await server.CreateClient()
|
||||||
// .GetAsync(Get.UserLocationBy(userId));
|
.GetAsync(Get.UserLocationBy(userId));
|
||||||
|
|
||||||
// var responseBody = await userLocationResponse.Content.ReadAsStringAsync();
|
var responseBody = await userLocationResponse.Content.ReadAsStringAsync();
|
||||||
// var userLocation = JsonConvert.DeserializeObject<UserLocation>(responseBody);
|
var userLocation = JsonConvert.DeserializeObject<UserLocation>(responseBody);
|
||||||
|
|
||||||
// var locationResponse = await server.CreateClient()
|
var locationResponse = await server.CreateClient()
|
||||||
// .GetAsync(Get.LocationBy(userLocation.LocationId));
|
.GetAsync(Get.LocationBy(userLocation.LocationId));
|
||||||
|
|
||||||
// responseBody = await locationResponse.Content.ReadAsStringAsync();
|
responseBody = await locationResponse.Content.ReadAsStringAsync();
|
||||||
// var location = JsonConvert.DeserializeObject<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>(responseBody);
|
var location = JsonConvert.DeserializeObject<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>(responseBody);
|
||||||
|
|
||||||
// // Assert
|
// Assert
|
||||||
// Assert.Equal(expectedLocation, location.Code);
|
Assert.Equal(expectedLocation, location.Code);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//[Fact]
|
[Fact]
|
||||||
//public async Task Get_all_locations_response_ok_status_code()
|
public async Task Get_all_locations_response_ok_status_code()
|
||||||
//{
|
{
|
||||||
// using (var server = CreateServer())
|
using (var server = CreateServer())
|
||||||
// {
|
{
|
||||||
// var response = await server.CreateClient()
|
var response = await server.CreateClient()
|
||||||
// .GetAsync(Get.Locations);
|
.GetAsync(Get.Locations);
|
||||||
|
|
||||||
// var responseBody = await response.Content.ReadAsStringAsync();
|
var responseBody = await response.Content.ReadAsStringAsync();
|
||||||
// var locations = JsonConvert.DeserializeObject<List<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>>(responseBody);
|
var locations = JsonConvert.DeserializeObject<List<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>>(responseBody);
|
||||||
|
|
||||||
// // Assert
|
// Assert
|
||||||
// Assert.NotEmpty(locations);
|
Assert.NotEmpty(locations);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
string BuildLocationsRequest(double lon, double lat)
|
string BuildLocationsRequest(double lon, double lat)
|
||||||
{
|
{
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
"IdentityUrl": "http://localhost:5105",
|
"IdentityUrl": "http://localhost:5105",
|
||||||
"isTest": "true",
|
"isTest": "true",
|
||||||
"EventBusConnection": "localhost",
|
"EventBusConnection": "localhost",
|
||||||
"SubscriptionClientName": "Locations"
|
"SubscriptionClientName": "Locations",
|
||||||
|
"SuppressCheckForUnhandledSecurityMetadata":true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user