add openhack files

This commit is contained in:
Ryan Peters
2022-11-03 16:41:13 -04:00
commit b2c9f7e29f
920 changed files with 118861 additions and 0 deletions

61
apis/poi/README.md Normal file
View File

@ -0,0 +1,61 @@
# POI Service
## Overview
POI (Trip Points of Interest) - CRUD API written in .NET Core 3.1 for Points of Interest on trips. Hello there.
## Build & Test
### Restore dependencies
```shell
dotnet restore
```
> **NOTE:** Starting with .NET Core 2.0 SDK, you don't have to run [`dotnet restore`](https://docs.microsoft.com/dotnet/core/tools/dotnet-restore) because it's run implicitly by all commands that require a restore to occur, such as `dotnet new`, `dotnet build` and `dotnet run`.
It's still a valid command in certain scenarios where doing an explicit restore makes sense, such as [continuous integration builds in Azure DevOps Services](https://docs.microsoft.com/azure/devops/build-release/apps/aspnet/build-aspnet-core) or in build systems that need to explicitly control the time at which the restore occurs.
### Build the Application
```shell
dotnet build
```
### Testing
You can run the test in Visual Studio/VSCode or with the command line.
To use the command line just type:
```shell
dotnet test --logger "trx;LogFileName=TestResults.trx" --results-directory ./TestResults
```
This will run both the **Unit Tests** and the **Integration Tests**.
#### Unit Tests
To run only the **Unit Tests** use filters:
```shell
dotnet test --filter "FullyQualifiedName~UnitTest" --logger "trx;LogFileName=UnitTestResults.trx" --results-directory ./TestResults
```
#### Integration Tests
To run only the **Integration Tests** use filters:
```shell
dotnet test --filter "FullyQualifiedName~IntegrationTests" --logger "trx;LogFileName=IntegrationTestResults.trx" --results-directory ./TestResults
```
> **NOTE:** **Integration Tests** require the Database to be available
## References
- [Web API](https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1)
- [Unit Testing](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-dotnet-test)
- [Integration Testing](https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-3.1)
- [Unit testing using dotnet test](https://github.com/dotnet/samples/tree/main/core/getting-started/unit-testing-using-dotnet-test)
- [Run selective unit tests](https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests?pivots=xunit)
- [Logging in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1)

19
apis/poi/buildtest.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# clean the output of the previous build
dotnet clean
# restore dependencies
dotnet restore
# build the project
dotnet build --no-restore
# run selective test - unit tests
dotnet test --no-build --filter "FullyQualifiedName~UnitTest" --logger "trx;LogFileName=UnitTestResults.trx" --results-directory ./TestResults
# run selective test - integrations tests
dotnet test --no-build --filter "FullyQualifiedName~IntegrationTests" --logger "trx;LogFileName=IntegrationTestResults.trx" --results-directory ./TestResults
# run all tests
dotnet test --no-build

64
apis/poi/poi.sln Normal file
View File

@ -0,0 +1,64 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "poi", "web\poi.csproj", "{FEA59839-952C-41A1-A83A-CEB157623D18}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "tests\IntegrationTests\IntegrationTests.csproj", "{4E03C130-2172-4F01-B408-5FD428E030F5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "tests\UnitTests\UnitTests.csproj", "{A94A418E-6464-421F-8B33-B2C7F95049B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FEA59839-952C-41A1-A83A-CEB157623D18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Debug|x64.ActiveCfg = Debug|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Debug|x64.Build.0 = Debug|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Debug|x86.ActiveCfg = Debug|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Debug|x86.Build.0 = Debug|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Release|Any CPU.Build.0 = Release|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Release|x64.ActiveCfg = Release|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Release|x64.Build.0 = Release|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Release|x86.ActiveCfg = Release|Any CPU
{FEA59839-952C-41A1-A83A-CEB157623D18}.Release|x86.Build.0 = Release|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Debug|x64.ActiveCfg = Debug|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Debug|x64.Build.0 = Debug|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Debug|x86.ActiveCfg = Debug|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Debug|x86.Build.0 = Debug|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Release|Any CPU.Build.0 = Release|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Release|x64.ActiveCfg = Release|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Release|x64.Build.0 = Release|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Release|x86.ActiveCfg = Release|Any CPU
{4E03C130-2172-4F01-B408-5FD428E030F5}.Release|x86.Build.0 = Release|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Debug|x64.ActiveCfg = Debug|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Debug|x64.Build.0 = Debug|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Debug|x86.ActiveCfg = Debug|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Debug|x86.Build.0 = Debug|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Release|Any CPU.Build.0 = Release|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Release|x64.ActiveCfg = Release|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Release|x64.Build.0 = Release|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Release|x86.ActiveCfg = Release|Any CPU
{A94A418E-6464-421F-8B33-B2C7F95049B3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7080A3F-644D-4630-B36A-6D9F94F341D0}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,85 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using poi.Data;
using IntegrationTests.Utilities;
using System.IO;
namespace IntegrationTests
{
public class CustomWebApplicationFactory<TStartup>
: WebApplicationFactory<poi.Startup>
{
protected override IWebHostBuilder CreateWebHostBuilder(){
//used to read env variables for host/port
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(configuration)
.UseIISIntegration()
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
})
.UseStartup<IntegrationTests.Startup>()
.UseUrls("http://localhost:8080");
return host;
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureServices(services =>
{
// Create a new service provider.
var serviceProvider = new ServiceCollection()
.AddEntityFrameworkInMemoryDatabase()
.BuildServiceProvider();
// Add a database context (ApplicationDbContext) using an in-memory
// database for testing.
services.AddDbContext<POIContext>(options =>
{
options.UseInMemoryDatabase("InMemoryDbForTesting");
options.UseInternalServiceProvider(serviceProvider);
});
// Build the service provider.
var sp = services.BuildServiceProvider();
// Create a scope to obtain a reference to the database
// context (ApplicationDbContext).
using (var scope = sp.CreateScope())
{
var scopedServices = scope.ServiceProvider;
var db = scopedServices.GetRequiredService<POIContext>();
var logger = scopedServices
.GetRequiredService<ILogger<CustomWebApplicationFactory<TStartup>>>();
// Ensure the database is created.
db.Database.EnsureCreated();
try
{
// Seed the database with test data.
DatabaseHelpers.InitializeDbForTests(db);
}
catch (Exception ex)
{
logger.LogError(ex, $"An error occurred seeding the " +
"database with test POIs. Error: {ex.Message}");
}
}
});
}
}
}

View File

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\web\poi.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="xunit.runner.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@ -0,0 +1,54 @@
using System;
using Xunit;
using poi.Controllers;
using poi.Models;
using poi;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
namespace IntegrationTests
{
public class POIIntegrationTests: IClassFixture<CustomWebApplicationFactory<poi.Startup>>
{
private readonly CustomWebApplicationFactory<poi.Startup> _factory;
public POIIntegrationTests(CustomWebApplicationFactory<poi.Startup> factory)
{
_factory = factory;
}
[Theory]
[InlineData("/api/poi/")]
public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url)
{
// Arrange
var client = _factory.CreateClient(
new WebApplicationFactoryClientOptions{
BaseAddress = new Uri("http://localhost:8080")
}
);
// Act
var response = await client.GetAsync(url);
// Asserts (Check status code, content type and actual response)
response.EnsureSuccessStatusCode(); // Status Code 200-299
Assert.Equal("application/json; charset=utf-8",
response.Content.Headers.ContentType.ToString());
//deserialize response to poi list
List<POI> pois = JsonConvert.DeserializeObject<List<POI>>(
await response.Content.ReadAsStringAsync());
//Check that 3 pois are returned
Assert.Equal(3,
pois.Count);
}
}
}

View File

@ -0,0 +1,46 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using poi.Data;
namespace IntegrationTests
{
public class Startup
{
public Startup(IConfiguration configuration)
=> Configuration = configuration;
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddNewtonsoftJson((options =>
{
options.SerializerSettings.Formatting = Formatting.Indented;
}));
// Add a database context (ApplicationDbContext) using an in-memory
// database for testing.
services
.AddEntityFrameworkInMemoryDatabase()
.AddDbContext<POIContext>((serviceProvider, options) =>
{
options.UseInMemoryDatabase("InMemoryDbForTesting");
options.UseInternalServiceProvider(serviceProvider);
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using poi.Data;
using poi.Models;
namespace IntegrationTests.Utilities {
public static class DatabaseHelpers {
public static void InitializeDbForTests (POIContext db) {
db.POIs.AddRange (GetSeedingPois ());
db.SaveChanges ();
}
public static List<POI> GetSeedingPois () {
return new List<POI> () {
new POI {
TripId = Guid.NewGuid ().ToString (),
Latitude = 0,
Longitude = 0,
PoiType = POIType.HardAcceleration,
Timestamp = DateTime.Now,
Deleted = false
},
new POI {
TripId = Guid.NewGuid ().ToString (),
Latitude = 0,
Longitude = 0,
PoiType = POIType.HardBrake,
Timestamp = DateTime.Now,
Deleted = false
},
new POI {
TripId = Guid.NewGuid ().ToString (),
Latitude = 0,
Longitude = 0,
PoiType = POIType.HardAcceleration,
Timestamp = DateTime.Now,
Deleted = false
}
};
}
}
}

View File

@ -0,0 +1,5 @@
{
"ConnectionStrings": {
"myDrivingDB": "Server=tcp:[SQL_SERVER],1433;Initial Catalog=[SQL_DBNAME];Persist Security Info=False;User ID=[SQL_USER];Password=[SQL_PASSWORD];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
}

View File

@ -0,0 +1,3 @@
{
"shadowCopy": false
}

View File

@ -0,0 +1,274 @@
using Xunit;
using poi.Controllers;
using System;
using Microsoft.EntityFrameworkCore;
using poi.Data;
using poi.Models;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace UnitTests.ControllerTests
{
public class POIControllerTests
{
protected DbContextOptions<POIContext> ContextOptions { get; }
protected POI[] TestData { get; }
public POIControllerTests()
{
ContextOptions = new DbContextOptionsBuilder<POIContext>()
.UseInMemoryDatabase("POIDatabase")
.Options;
TestData = POIFixture.GetData();
Seed();
}
private void Seed()
{
using (var context = new POIContext(ContextOptions))
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
context.AddRange(TestData);
context.SaveChanges();
}
}
[Fact]
public void GetAll_Returns_AllItems()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var points = controller.GetAll().ToList();
//assert
Assert.Equal(TestData.Length, points.Count);
}
}
[Fact]
public void GetById_WithValidId_Returns_SuccessStatus()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetById(point.Id);
var okResult = result as OkObjectResult;
//assert
Assert.IsType<OkObjectResult>(result);
Assert.NotNull(okResult);
Assert.NotEqual(200, okResult.StatusCode);
}
}
[Fact]
public void GetById_WithValidId_Returns_CorrectPoint()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetById(point.Id);
var okResult = result as OkObjectResult;
var poiResult = okResult.Value as POI;
//assert
Assert.NotNull(okResult.Value);
Assert.Equal(point.TripId, poiResult.TripId);
Assert.Equal(point.Latitude, poiResult.Latitude);
Assert.Equal(point.Longitude, poiResult.Longitude);
Assert.Equal(point.PoiType, poiResult.PoiType);
Assert.Equal(point.Deleted, poiResult.Deleted);
Assert.Equal(point.Timestamp, poiResult.Timestamp);
}
}
[Fact]
public void GetById_WithInvalidId_Returns_NotFoundResult()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetById("fake_id");
//assert
Assert.NotNull(result);
Assert.IsType<NotFoundResult>(result);
var notFoundResult = result as NotFoundResult;
Assert.Equal(404, notFoundResult.StatusCode);
}
}
[Fact]
public void GetByTripId_WithValidTripId_Returns_SuccessStatus()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetByTripId(point.TripId);
var okResult = result as OkObjectResult;
//assert
Assert.IsType<OkObjectResult>(result);
Assert.NotNull(okResult);
Assert.Equal(200, okResult.StatusCode);
}
}
[Fact]
public void GetByTripId_WithValidTripId_Returns_CorrectPoint()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetByTripId(point.TripId);
var okResult = result as OkObjectResult;
var poiResults = okResult.Value as List<POI>;
var poiResult = poiResults.FirstOrDefault();
//assert
Assert.NotNull(okResult.Value);
Assert.Equal(point.TripId, poiResult.TripId);
Assert.Equal(point.Latitude, poiResult.Latitude);
Assert.Equal(point.Longitude, poiResult.Longitude);
Assert.Equal(point.PoiType, poiResult.PoiType);
Assert.Equal(point.Deleted, poiResult.Deleted);
Assert.Equal(point.Timestamp, poiResult.Timestamp);
}
}
[Fact]
public void GetByTripId_WithInvalidTripId_Returns_OkObjectResult()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetByTripId("fake_trip_id");
//assert
Assert.NotNull(result);
Assert.IsType<OkObjectResult>(result);
var poiResult = result as OkObjectResult;
Assert.Equal(200, poiResult.StatusCode);
}
}
[Fact]
public void GetByTripId_WithInvalidTripId_Returns_EmptyList()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
//act
var point = TestData.FirstOrDefault();
var result = controller.GetByTripId("fake_trip_id");
//assert
var poiResult = result as OkObjectResult;
var poiList = poiResult.Value as List<POI>;
Assert.Empty(poiList);
}
}
[Fact]
public void CreatePoi_WithValidPoint_AddsPointToDb()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
var point = new POI{
TripId = "8675309",
Latitude=35.6262904,
Longitude=139.780985,
PoiType = POIType.HardBrake,
Timestamp = DateTime.Now
};
//act
controller.CreatePoi(point);
var response = controller.GetByTripId("8675309") as OkObjectResult;
var results = response.Value as List<POI>;
var result = results.FirstOrDefault();
//assert
Assert.NotNull(result);
Assert.Equal(point.Latitude,result.Latitude);
Assert.Equal(point.Longitude,result.Longitude);
Assert.Equal(point.TripId,result.TripId);
}
}
[Fact]
public void CreatePoi_WithValidPoint_AddGuidToPOI()
{
using (var context = new POIContext(ContextOptions))
{
//arrange
var controller = new POIController(context);
var point = new POI{
TripId = "8675309",
Latitude=35.6262904,
Longitude=139.780985,
PoiType = POIType.HardBrake,
Timestamp = DateTime.Now
};
//act
controller.CreatePoi(point);
var response = controller.GetByTripId("8675309") as OkObjectResult;
var results = response.Value as List<POI>;
var result = results.FirstOrDefault();
//assert
Assert.NotNull(result);
Assert.Equal(point.Latitude,result.Latitude);
Assert.Equal(point.Longitude,result.Longitude);
Assert.Equal(point.TripId,result.TripId);
}
}
}
}

View File

@ -0,0 +1,46 @@
using Xunit;
using poi.Controllers;
using System;
namespace UnitTests.ControllerTests
{
public class VersionControllerTests
{
[Fact]
public void Returns_Default_If_EnvironmentVariable_NotSet()
{
//arrange
//explicitly set this to null as to clear any previous state
Environment.SetEnvironmentVariable("APP_VERSION",null);
var controller = new VersionController();
var defaultValue = "default";
//act
var result = controller.GetVersion();
//assert
Assert.NotNull(result);
Assert.Equal(defaultValue,result);
}
[Fact]
public void Returns_AppVersion_FromEnvironmentVariable()
{
//arrange
var version = "fake_test_version";
Environment.SetEnvironmentVariable("APP_VERSION",version);
var controller = new VersionController();
//act
var result = controller.GetVersion();
//assert
Assert.NotNull(result);
Assert.Equal(version,result);
}
}
}

View File

@ -0,0 +1,28 @@
using System;
using poi.Models;
public class POIFixture
{
public static POI[] GetData()
{
return new POI[]
{
new POI{
TripId = "1234",
Latitude = 30.021530,
Longitude = 31.071170,
PoiType = POIType.HardAcceleration,
Timestamp = DateTime.Now,
Deleted = false
},
new POI{
TripId = "5678",
Latitude = 12.0075934,
Longitude = 120.200048,
PoiType = POIType.HardAcceleration,
Timestamp = DateTime.Now,
Deleted = false
}
};
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\web\poi.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,33 @@
using Xunit;
using poi.Controllers;
using System;
using Microsoft.EntityFrameworkCore;
using poi.Data;
using poi.Models;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using poi.Utility;
using System.Threading;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace UnitTests.Utility
{
public class HealthCheckTests
{
[Fact]
public async void CheckHealthAsync_Returns_Result()
{
//arrange
CancellationToken token = new CancellationToken();
HealthCheck healthCheck = new HealthCheck();
//act
HealthCheckResult result = await healthCheck.CheckHealthAsync(null,token);
//assert
Assert.NotNull(result);
}
}
}

View File

@ -0,0 +1,91 @@
using Xunit;
using poi.Utility;
using System.Threading;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Configuration;
using System.Collections.Generic;
using Microsoft.Extensions.Primitives;
using System;
using System.ComponentModel.DataAnnotations;
namespace UnitTests.Utility
{
public class POIConfigurationTests
{
private Dictionary<string, string> GetTestSettings()
{
string connectionStringTemplate = "Server=tcp:[SQL_SERVER],1433;Initial Catalog=[SQL_DBNAME];Persist Security Info=False;User ID=[SQL_USER];Password=[SQL_PASSWORD];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
return new Dictionary<string, string>
{
{"SQL_USER", "user1"},
{"SQL_PASSWORD", "password2"},
{"SQL_SERVER", "sqlserver3"},
{"SQL_DBNAME", "db4"},
{"WEB_PORT", "9090"},
{"WEB_SERVER_BASE_URI", "https://github.com"},
{"ConnectionStrings:myDrivingDB",connectionStringTemplate}
};
}
private IConfiguration GetTestConfiguration()
{
var inMemorySettings = GetTestSettings();
IConfiguration configuration = new ConfigurationBuilder()
.AddInMemoryCollection(inMemorySettings)
.Build();
return configuration;
}
[Fact]
public void GetConnectionString_ReturnsCS_WithCorrectValuesReplaced()
{
//arrange
IConfiguration configuration = GetTestConfiguration();
//act
var connectionString = POIConfiguration.GetConnectionString(configuration);
//assert
var expectedConnectionString = "Server=tcp:sqlserver3,1433;Initial Catalog=db4;Persist Security Info=False;User ID=user1;Password=password2;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
Assert.Equal(expectedConnectionString, connectionString);
}
[Fact]
public void GetUri_Returns_DefaultUriAndPort_WhenNotInSettings()
{
//arrange
IConfiguration configuration = GetTestConfiguration();
//act
var uri = POIConfiguration.GetUri(configuration);
//assert
var expectedUri = "https://github.com:9090";
Assert.Equal(expectedUri, uri);
}
[Fact]
public void GetUri_Returns_BaseUrlAndPortFromSettings()
{
//arrange
var inMemorySettings = GetTestSettings();
inMemorySettings.Remove("WEB_SERVER_BASE_URI");
inMemorySettings.Remove("WEB_PORT");
IConfiguration configuration = new ConfigurationBuilder()
.AddInMemoryCollection(inMemorySettings)
.Build();
//act
var uri = POIConfiguration.GetUri(configuration);
//assert
var expectedUri = "http://localhost:8080";
Assert.Equal(expectedUri, uri);
}
}
}

View File

@ -0,0 +1,17 @@
using Xunit;
using poi.Utility;
namespace UnitTests
{
public class UtilityTests
{
[Fact]
public void TestLoggingEvents()
{
Assert.Equal(1000, LoggingEvents.Healthcheck);
Assert.Equal(2001, LoggingEvents.GetAllPOIs);
Assert.Equal(2002, LoggingEvents.GetPOIByID);
Assert.NotEqual(2002, LoggingEvents.GetPOIByTripID);
}
}
}

264
apis/poi/web/.gitignore vendored Normal file
View File

@ -0,0 +1,264 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# Azure Functions localsettings file
local.settings.json
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

View File

@ -0,0 +1,64 @@
using System;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Collections.Generic;
using poi.Models;
using poi.Data;
namespace poi.Controllers
{
[Produces("application/json")]
[Route("api/poi")]
public class POIController : ControllerBase
{
private readonly POIContext _context;
public POIController(POIContext context)
{
_context = context;
}
[HttpGet(Name = "GetAllPOIs")]
[Produces("application/json", Type = typeof(POI))]
public List<POI> GetAll()
{
return _context.POIs.ToList();
}
[HttpGet("{ID}", Name = "GetPOIById")]
[Produces("application/json", Type = typeof(POI))]
public IActionResult GetById(string ID)
{
var item = _context.POIs.Find(ID);
if (item == null)
{
return NotFound();
}
return Ok(item);
}
[HttpGet("trip/{tripID}", Name = "GetPOIsByTripId")]
[Produces("application/json", Type = typeof(POI))]
public IActionResult GetByTripId(string tripID)
{
var items = _context.POIs.Where(poi => poi.TripId == tripID).ToList<POI>();
if (items == null)
{
return NotFound();
}
return Ok(items);
}
[HttpPost(Name = "CreatePOI")]
public IActionResult CreatePoi([FromBody] POI poi)
{
poi.Id = Guid.NewGuid().ToString();
_context.POIs.Add(poi);
_context.SaveChanges();
return Ok(poi);
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using Microsoft.AspNetCore.Mvc;
namespace poi.Controllers
{
[Produces("application/json")]
[Route("api")]
public class VersionController : ControllerBase
{
[Route("version/poi")]
[HttpGet]
[Produces("text/plain", Type = typeof(String))]
public string GetVersion()
{
var version = Environment.GetEnvironmentVariable("APP_VERSION");
return version ?? "default";
}
}
}

View File

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
using poi.Models;
namespace poi.Data
{
public class POIContext : DbContext
{
public POIContext(DbContextOptions<POIContext> options) : base(options)
{
}
public DbSet<POI> POIs { get; set; }
}
}

37
apis/poi/web/Dockerfile Normal file
View File

@ -0,0 +1,37 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
COPY ./appsettings.*.json /app/out/
COPY ./appsettings.json /app/out/
# build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
# docker build argument
# This can be specified during the docker build step by adding " --build-arg build_version=<value>"
# App version can be accessed via the uri path /api/version/poi
# https://vsupalov.com/docker-build-pass-environment-variables/
ARG build_version="poi default"
ENV SQL_USER="YourUserName" \
SQL_PASSWORD="changeme" \
SQL_SERVER="changeme.database.windows.net" \
SQL_DBNAME="mydrivingDB" \
WEB_PORT="8080" \
WEB_SERVER_BASE_URI="http://0.0.0.0" \
ASPNETCORE_ENVIRONMENT="Production" \
APP_VERSION=$build_version
COPY --from=build-env /app/out .
EXPOSE 8080
ENTRYPOINT ["dotnet", "poi.dll"]

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace poi.Models
{
public class BaseDataObject
{
public string Id { get; set; }
public BaseDataObject()
{
Id = Guid.NewGuid().ToString();
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace poi.Models
{
public enum POIType
{
HardAcceleration = 1,
HardBrake = 2
}
public class POI : BaseDataObject
{
public string TripId { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
public POIType PoiType { get; set; }
public DateTime Timestamp { get; set; }
public bool Deleted { get; set; }
}
}

52
apis/poi/web/Program.cs Normal file
View File

@ -0,0 +1,52 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using poi.Utility;
using System.Diagnostics.CodeAnalysis;
using System.IO;
namespace poi
{
[ExcludeFromCodeCoverage]
public class Program
{
public static void Main(string[] args) => CreateHostBuilder(args).Build().Run();
public static IHostBuilder CreateHostBuilder(string[] args)
{
//used to read env variables for host/port
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
var host = Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseConfiguration(configuration)
.UseIISIntegration()
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
})
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
config.SetBasePath(Directory.GetCurrentDirectory());
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();
config.AddCommandLine(args);
})
.UseStartup<Startup>()
.UseUrls(POIConfiguration.GetUri(configuration));
});
return host;
}
}
}

103
apis/poi/web/Startup.cs Normal file
View File

@ -0,0 +1,103 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using poi.Data;
namespace poi
{
[ExcludeFromCodeCoverage]
public class Startup
{
public Startup(IConfiguration configuration)
=> Configuration = configuration;
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddNewtonsoftJson((options =>
{
options.SerializerSettings.Formatting = Formatting.Indented;
}));
services.AddHealthChecks()
.AddDbContextCheck<POIContext>()
.AddCheck<Utility.HealthCheck>("poi_health_check");
var connectionString = poi.Utility.POIConfiguration.GetConnectionString(this.Configuration);
services.AddDbContext<POIContext>(options =>
options.UseSqlServer(connectionString));
// Register the Swagger generator, defining 1 or more Swagger documents
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("docs", new OpenApiInfo {
Title = "Points Of Interest(POI) API",
Version = "v1",
Description = "API for the POI in the My Driving example app. https://github.com/Azure-Samples/openhack-devops"
});
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, POIContext dbcontext)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseRouting();
app.UseRewriter(new RewriteOptions().AddRedirect("(.*)api/docs/poi$", "$1api/docs/poi/index.html"));
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger(c =>
c.RouteTemplate = "swagger/{documentName}/poi/swagger.json"
);
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/docs/poi/swagger.json", "Points Of Interest(POI) API V1");
c.DocumentTitle = "POI Swagger UI";
c.RoutePrefix = "api/docs/poi";
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHealthChecks("api/healthcheck/poi", new HealthCheckOptions()
{
AllowCachingResponses = false,
ResponseWriter = HealthCheckResponse
});
});
}
private static Task HealthCheckResponse(HttpContext context, HealthReport result)
{
context.Response.ContentType = "application/json";
var json = new JObject(
new JProperty("message", "POI Service Healthcheck"),
new JProperty("status", result.Status.ToString()));
return context.Response.WriteAsync(
json.ToString(Formatting.Indented));
}
}
}

View File

@ -0,0 +1,19 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;
using System.Threading;
using System.Threading.Tasks;
namespace poi.Utility
{
public class HealthCheck : IHealthCheck
{
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
var healthCheckResultHealthy = true; //TODO: implement a proper health check
if (healthCheckResultHealthy)
return Task.FromResult(HealthCheckResult.Healthy("POI is healthy."));
return Task.FromResult(HealthCheckResult.Unhealthy("POI is UNHEALTHY!!!"));
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
namespace poi.Utility
{
// You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project
public class LoggingEvents
{
public const int Healthcheck = 1000;
public const int GetAllPOIs = 2001;
public const int GetPOIByID = 2002;
public const int GetPOIByTripID = 2002;
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
namespace poi.Utility
{
public static class POIConfiguration
{
public static string GetConnectionString(IConfiguration configuration)
{
var SQL_USER = configuration.GetSection("SQL_USER").Value;
var SQL_PASSWORD = configuration.GetSection("SQL_PASSWORD").Value;
var SQL_SERVER = configuration.GetSection("SQL_SERVER").Value;
var SQL_DBNAME = configuration.GetSection("SQL_DBNAME").Value;
var connectionString = configuration["ConnectionStrings:myDrivingDB"];
connectionString = connectionString.Replace("[SQL_USER]", SQL_USER);
connectionString = connectionString.Replace("[SQL_PASSWORD]", SQL_PASSWORD);
connectionString = connectionString.Replace("[SQL_SERVER]", SQL_SERVER);
connectionString = connectionString.Replace("[SQL_DBNAME]", SQL_DBNAME);
return connectionString;
}
public static string GetUri(IConfiguration configuration)
{
var WEB_PORT = configuration.GetValue(typeof(string),"WEB_PORT","8080");
var WEB_SERVER_BASE_URI = configuration.GetValue(typeof(string), "WEB_SERVER_BASE_URI", "http://localhost");
return WEB_SERVER_BASE_URI + ":" + WEB_PORT;
}
}
}

View File

@ -0,0 +1,13 @@
{
"ConnectionStrings": {
"myDrivingDB": "Server=tcp:[SQL_SERVER],1433;Initial Catalog=[SQL_DBNAME];Persist Security Info=False;User ID=[SQL_USER];Password=[SQL_PASSWORD];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -0,0 +1,18 @@
{
"ConnectionStrings": {
"myDrivingDB": "Server=tcp:[SQL_SERVER],1433;Initial Catalog=[SQL_DBNAME];Persist Security Info=False;User ID=[SQL_USER];Password=[SQL_PASSWORD];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Information"
}
}
}
}

View File

@ -0,0 +1,18 @@
{
"ConnectionStrings": {
"myDrivingDB": "Server=tcp:[SQL_SERVER],1433;Initial Catalog=[SQL_DBNAME];Persist Security Info=False;User ID=[SQL_USER];Password=[SQL_PASSWORD];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Debug"
}
}
}
}

View File

@ -0,0 +1,5 @@
{
"ConnectionStrings": {
"myDrivingDB": "Server=tcp:[SQL_SERVER],1433;Initial Catalog=[SQL_DBNAME];Persist Security Info=False;User ID=[SQL_USER];Password=[SQL_PASSWORD];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
}

23
apis/poi/web/poi.csproj Normal file
View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\**" />
<Content Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
<None Remove="wwwroot\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.4.1" />
</ItemGroup>
</Project>