Commit f2cb9398 authored by Steve Smith's avatar Steve Smith

Merge remote-tracking branch 'origin/dotnetcore2.0'

parents 2acb37ee b1fe6cf5
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>CleanArchitecture.Core</AssemblyName>
<PackageId>CleanArchitecture.Core</PackageId>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup> <PropertyGroup>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>CleanArchitecture.Infrastructure</AssemblyName>
<PackageId>CleanArchitecture.Infrastructure</PackageId>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
...@@ -14,7 +13,8 @@ ...@@ -14,7 +13,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="StructureMap.Microsoft.DependencyInjection" Version="1.3.0" /> <PackageReference Include="StructureMap.Microsoft.DependencyInjection" Version="1.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>CleanArchitecture.Web</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>CleanArchitecture.Web</PackageId>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
......
...@@ -44,7 +44,7 @@ namespace CleanArchitecture.Web.Controllers ...@@ -44,7 +44,7 @@ namespace CleanArchitecture.Web.Controllers
Title = "Run and Review Tests", Title = "Run and Review Tests",
Description = "Make sure all the tests run and review what they are doing." Description = "Make sure all the tests run and review what they are doing."
}); });
return 3; return _todoRepository.List().Count;
} }
} }
} }
using System; using Microsoft.AspNetCore.Hosting;
using System.Collections.Generic; using Microsoft.AspNetCore;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
namespace CleanArchitecture.Web namespace CleanArchitecture.Web
{ {
...@@ -11,14 +7,12 @@ namespace CleanArchitecture.Web ...@@ -11,14 +7,12 @@ namespace CleanArchitecture.Web
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
var host = new WebHostBuilder() BuildWebHost(args).Run();
.UseKestrel() }
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();
host.Run();
}
} }
} }
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57678/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"CleanArchitecture.Web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:57679/"
}
}
}
\ No newline at end of file
using CleanArchitecture.Core.Entities;
using CleanArchitecture.Infrastructure.Data;
namespace CleanArchitecture.Web
{
public static class SeedData
{
public static void PopulateTestData(AppDbContext dbContext)
{
var toDos = dbContext.ToDoItems;
foreach (var item in toDos)
{
dbContext.Remove(item);
}
dbContext.SaveChanges();
dbContext.ToDoItems.Add(new ToDoItem()
{
Title = "Test Item 1",
Description = "Test Description One"
});
dbContext.ToDoItems.Add(new ToDoItem()
{
Title = "Test Item 2",
Description = "Test Description Two"
});
dbContext.SaveChanges();
}
}
}
using System; using System;
using CleanArchitecture.Core.Interfaces; using CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Core.Entities;
using CleanArchitecture.Core.SharedKernel; using CleanArchitecture.Core.SharedKernel;
using CleanArchitecture.Infrastructure;
using CleanArchitecture.Infrastructure.Data; using CleanArchitecture.Infrastructure.Data;
using CleanArchitecture.Infrastructure.DomainEvents;
using CleanArchitecture.Web.ApiModels;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using StructureMap; using StructureMap;
using StructureMap.AutoMocking;
namespace CleanArchitecture.Web namespace CleanArchitecture.Web
{ {
public class Startup public class Startup
{ {
public Startup(IHostingEnvironment env) public Startup(IConfiguration config)
{ {
var builder = new ConfigurationBuilder() Configuration = config;
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
} }
public IConfigurationRoot Configuration { get; } public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services) public IServiceProvider ConfigureServices(IServiceCollection services)
{ {
// Add framework services.
// TODO: Add DbContext and IOC // TODO: Add DbContext and IOC
string dbName = Guid.NewGuid().ToString(); string dbName = Guid.NewGuid().ToString();
services.AddDbContext<AppDbContext>(options => services.AddDbContext<AppDbContext>(options =>
options.UseInMemoryDatabase(dbName)); options.UseInMemoryDatabase(dbName));
//options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc(); services.AddMvc()
.AddControllersAsServices();
var container = new Container(); var container = new Container();
...@@ -75,36 +62,10 @@ namespace CleanArchitecture.Web ...@@ -75,36 +62,10 @@ namespace CleanArchitecture.Web
ILoggerFactory loggerFactory) ILoggerFactory loggerFactory)
{ {
this.Configure(app, env, loggerFactory); this.Configure(app, env, loggerFactory);
PopulateTestData(app); SeedData.PopulateTestData(app.ApplicationServices.GetService<AppDbContext>());
//var authorRepository = app.ApplicationServices
// .GetService<IAuthorRepository>();
//Task.Run(() => PopulateSampleData(authorRepository));
}
private void PopulateTestData(IApplicationBuilder app)
{
var dbContext = app.ApplicationServices.GetService<AppDbContext>();
var toDos = dbContext.ToDoItems;
foreach (var item in toDos)
{
dbContext.Remove(item);
}
dbContext.SaveChanges();
dbContext.ToDoItems.Add(new ToDoItem()
{
Title = "Test Item 1",
Description = "Test Description One"
});
dbContext.ToDoItems.Add(new ToDoItem()
{
Title = "Test Item 2",
Description = "Test Description Two"
});
dbContext.SaveChanges();
} }
// 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, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddConsole(Configuration.GetSection("Logging"));
......
{ {
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\v11.0;Database=cleanarchitecture;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": { "Logging": {
"IncludeScopes": false, "IncludeScopes": false,
"LogLevel": { "LogLevel": {
......
...@@ -3,7 +3,6 @@ using Xunit; ...@@ -3,7 +3,6 @@ using Xunit;
namespace CleanArchitecture.Tests.Integration.Web namespace CleanArchitecture.Tests.Integration.Web
{ {
public class HomeControllerContactShould : BaseWebTest public class HomeControllerContactShould : BaseWebTest
{ {
[Fact] [Fact]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment