Commit f2cb9398 authored by Steve Smith's avatar Steve Smith

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

parents 2acb37ee b1fe6cf5
......@@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>CleanArchitecture.Core</AssemblyName>
<PackageId>CleanArchitecture.Core</PackageId>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>CleanArchitecture.Infrastructure</AssemblyName>
<PackageId>CleanArchitecture.Infrastructure</PackageId>
</PropertyGroup>
<ItemGroup>
......@@ -14,7 +13,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<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>
......
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>CleanArchitecture.Web</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>CleanArchitecture.Web</PackageId>
</PropertyGroup>
<PropertyGroup>
......
......@@ -44,7 +44,7 @@ namespace CleanArchitecture.Web.Controllers
Title = "Run and Review Tests",
Description = "Make sure all the tests run and review what they are doing."
});
return 3;
return _todoRepository.List().Count;
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore;
namespace CleanArchitecture.Web
{
......@@ -11,14 +7,12 @@ namespace CleanArchitecture.Web
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.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 CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Core.Entities;
using CleanArchitecture.Core.SharedKernel;
using CleanArchitecture.Infrastructure;
using CleanArchitecture.Infrastructure.Data;
using CleanArchitecture.Infrastructure.DomainEvents;
using CleanArchitecture.Web.ApiModels;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using StructureMap;
using StructureMap.AutoMocking;
namespace CleanArchitecture.Web
{
public class Startup
{
public Startup(IHostingEnvironment env)
public Startup(IConfiguration config)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = config;
}
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)
{
// Add framework services.
// TODO: Add DbContext and IOC
string dbName = Guid.NewGuid().ToString();
services.AddDbContext<AppDbContext>(options =>
options.UseInMemoryDatabase(dbName));
//options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc();
services.AddMvc()
.AddControllersAsServices();
var container = new Container();
......@@ -75,36 +62,10 @@ namespace CleanArchitecture.Web
ILoggerFactory loggerFactory)
{
this.Configure(app, env, loggerFactory);
PopulateTestData(app);
//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();
SeedData.PopulateTestData(app.ApplicationServices.GetService<AppDbContext>());
}
// 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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
......
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\v11.0;Database=cleanarchitecture;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
......
......@@ -3,7 +3,6 @@ using Xunit;
namespace CleanArchitecture.Tests.Integration.Web
{
public class HomeControllerContactShould : BaseWebTest
{
[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