merge
This commit is contained in:
commit
27f04fefac
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Locations.API.Model.Core
|
||||
{
|
||||
public class LocationPoint
|
||||
{
|
||||
public LocationPoint()
|
||||
{
|
||||
}
|
||||
|
||||
public LocationPoint(double longitude, double latitude)
|
||||
{
|
||||
this.coordinates.Add(longitude);
|
||||
this.coordinates.Add(latitude);
|
||||
}
|
||||
|
||||
public string type { get; private set; } = "Point";
|
||||
|
||||
public List<double> coordinates { get; private set; } = new List<double>();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using MongoDB.Driver.GeoJsonObjectModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Locations.API.Model.Core
|
||||
{
|
||||
public class LocationPolygon
|
||||
{
|
||||
public LocationPolygon()
|
||||
{
|
||||
}
|
||||
|
||||
public LocationPolygon(List<GeoJson2DGeographicCoordinates> coordinatesList)
|
||||
{
|
||||
var coordinatesMapped = coordinatesList.Select(x => new List<double>() { x.Longitude, x.Latitude }).ToList();
|
||||
this.coordinates.Add(coordinatesMapped);
|
||||
}
|
||||
|
||||
public string type { get; private set; } = "Polygon";
|
||||
|
||||
public List<List<List<double>>> coordinates { get; private set; } = new List<List<List<double>>>();
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Locations.API.Model
|
||||
{
|
||||
using global::Locations.API.Model.Core;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Driver.GeoJsonObjectModel;
|
||||
@ -17,8 +18,12 @@
|
||||
public string Description { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public GeoJsonPoint<GeoJson2DGeographicCoordinates> Location { get; private set; }
|
||||
public GeoJsonPolygon<GeoJson2DGeographicCoordinates> Polygon { get; private set; }
|
||||
public LocationPoint Location { get; private set; }
|
||||
public LocationPolygon 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 SetArea(List<GeoJson2DGeographicCoordinates> coordinatesList) => SetPolygon(coordinatesList);
|
||||
|
||||
@ -26,14 +31,12 @@
|
||||
{
|
||||
Latitude = lat;
|
||||
Longitude = lon;
|
||||
Location = new GeoJsonPoint<GeoJson2DGeographicCoordinates>(
|
||||
new GeoJson2DGeographicCoordinates(lon, lat));
|
||||
Location = new LocationPoint(lon, lat);
|
||||
}
|
||||
|
||||
private void SetPolygon(List<GeoJson2DGeographicCoordinates> coordinatesList)
|
||||
{
|
||||
Polygon = new GeoJsonPolygon<GeoJson2DGeographicCoordinates>(new GeoJsonPolygonCoordinates<GeoJson2DGeographicCoordinates>(
|
||||
new GeoJsonLinearRingCoordinates<GeoJson2DGeographicCoordinates>(coordinatesList)));
|
||||
Polygon = new LocationPolygon(coordinatesList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using HealthChecks.UI.Client;
|
||||
using Locations.API.Controllers;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
@ -37,17 +38,18 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
RegisterAppInsights(services);
|
||||
|
||||
services.AddCustomHealthCheck(Configuration);
|
||||
|
||||
services.AddControllers(options =>
|
||||
{
|
||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
|
||||
}).AddNewtonsoftJson();
|
||||
{
|
||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
})
|
||||
.AddApplicationPart(typeof(LocationsController).Assembly)
|
||||
.AddNewtonsoftJson();
|
||||
|
||||
ConfigureAuthService(services);
|
||||
|
||||
@ -154,7 +156,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
//loggerFactory.AddAzureWebAppDiagnostics();
|
||||
//loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace);
|
||||
@ -167,9 +169,9 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
||||
|
||||
app.UseCors("CorsPolicy");
|
||||
|
||||
app.UseRouting();
|
||||
ConfigureAuth(app);
|
||||
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
|
@ -1,7 +1,11 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.eShopOnContainers.Services.Locations.API;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
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)
|
||||
{
|
||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(NetCoreTargetVersion)</TargetFramework>
|
||||
|
||||
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -17,8 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(Microsoft_AspNetCore_Mvc_Testing)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(Microsoft_NET_Test_Sdk)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(Microsoft_AspNetCore_TestHost)" />
|
||||
<PackageReference Include="xunit" Version="$(xunit)" />
|
||||
@ -26,7 +25,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -52,21 +52,24 @@ namespace Locations.FunctionalTests
|
||||
var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed";
|
||||
var content = new StringContent(BuildLocationsRequest(-122.119998, 47.690876), UTF8Encoding.UTF8, "application/json");
|
||||
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Expected result
|
||||
var expectedLocation = "REDM";
|
||||
|
||||
// Act
|
||||
var response = await server.CreateClient()
|
||||
.PostAsync(Post.AddNewLocation, content);
|
||||
|
||||
var userLocationResponse = await server.CreateClient()
|
||||
.GetAsync(Get.UserLocationBy(userId));
|
||||
var response = await client.PostAsync(Post.AddNewLocation, content);
|
||||
|
||||
var userLocationResponse = await client.GetAsync(Get.UserLocationBy(userId));
|
||||
userLocationResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var responseBody = await userLocationResponse.Content.ReadAsStringAsync();
|
||||
var userLocation = JsonConvert.DeserializeObject<UserLocation>(responseBody);
|
||||
|
||||
var locationResponse = await server.CreateClient()
|
||||
.GetAsync(Get.LocationBy(userLocation.LocationId));
|
||||
Assert.NotNull(userLocation);
|
||||
|
||||
var locationResponse = await client.GetAsync(Get.LocationBy(userLocation.LocationId));
|
||||
|
||||
responseBody = await locationResponse.Content.ReadAsStringAsync();
|
||||
var location = JsonConvert.DeserializeObject<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>(responseBody);
|
||||
|
@ -5,5 +5,6 @@
|
||||
"IdentityUrl": "http://localhost:5105",
|
||||
"isTest": "true",
|
||||
"EventBusConnection": "localhost",
|
||||
"SubscriptionClientName": "Locations"
|
||||
"SubscriptionClientName": "Locations",
|
||||
"SuppressCheckForUnhandledSecurityMetadata":true
|
||||
}
|
||||
|
@ -56,7 +56,7 @@
|
||||
<Microsoft_AspNetCore_HealthChecks>1.0.0</Microsoft_AspNetCore_HealthChecks>
|
||||
<Microsoft_AspNetCore_Http_Abstractions>2.2.0</Microsoft_AspNetCore_Http_Abstractions>
|
||||
<Microsoft_AspNetCore_Mvc_Testing>3.0.0-preview6.19307.2</Microsoft_AspNetCore_Mvc_Testing>
|
||||
<Microsoft_AspNetCore_TestHost>3.0.0-preview6.19307.2</Microsoft_AspNetCore_TestHost>
|
||||
<Microsoft_AspNetCore_TestHost>3.0.0-preview7.19365.7</Microsoft_AspNetCore_TestHost>
|
||||
<Microsoft_AspNetCore_Identity_EntityFrameworkCore>3.0.0-preview7.19365.7</Microsoft_AspNetCore_Identity_EntityFrameworkCore>
|
||||
<Microsoft_AspNetCore_Diagnostics_EntityFrameworkCore>3.0.0-preview7.19365.7</Microsoft_AspNetCore_Diagnostics_EntityFrameworkCore>
|
||||
<Microsoft_AspNetCore_Hosting_Abstractions>3.0.0-preview4-19123-01</Microsoft_AspNetCore_Hosting_Abstractions>
|
||||
@ -80,10 +80,10 @@
|
||||
<Microsoft_Extensions_Logging>2.2.0</Microsoft_Extensions_Logging>
|
||||
<Microsoft_Extensions_Logging_AzureAppServices>3.0.0-preview7.19362.4</Microsoft_Extensions_Logging_AzureAppServices>
|
||||
<Microsoft_NET_Test_Sdk>16.0.1</Microsoft_NET_Test_Sdk>
|
||||
<mongocsharpdriver>2.5.0</mongocsharpdriver>
|
||||
<MongoDB_Bson>2.5.0</MongoDB_Bson>
|
||||
<MongoDB_Driver>2.5.0</MongoDB_Driver>
|
||||
<MongoDB_Driver_Core>2.5.0</MongoDB_Driver_Core>
|
||||
<mongocsharpdriver>2.9.0-beta2</mongocsharpdriver>
|
||||
<MongoDB_Bson>2.9.0-beta2</MongoDB_Bson>
|
||||
<MongoDB_Driver>2.9.0-beta2</MongoDB_Driver>
|
||||
<MongoDB_Driver_Core>2.9.0-beta2</MongoDB_Driver_Core>
|
||||
<Moq>4.10.1</Moq>
|
||||
<Newtonsoft_Json>12.0.2</Newtonsoft_Json>
|
||||
<Ocelot>12.0.1</Ocelot>
|
||||
|
Loading…
x
Reference in New Issue
Block a user