Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CleanArchitecture
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CleanArchitecture
Commits
f2cb9398
Commit
f2cb9398
authored
Oct 23, 2017
by
Steve Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dotnetcore2.0'
parents
2acb37ee
b1fe6cf5
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
85 additions
and
65 deletions
+85
-65
CleanArchitecture.Core.csproj
src/CleanArchitecture.Core/CleanArchitecture.Core.csproj
+2
-0
CleanArchitecture.Infrastructure.csproj
...re.Infrastructure/CleanArchitecture.Infrastructure.csproj
+5
-5
CleanArchitecture.Web.csproj
src/CleanArchitecture.Web/CleanArchitecture.Web.csproj
+4
-0
ToDoController.cs
src/CleanArchitecture.Web/Controllers/ToDoController.cs
+1
-1
Program.cs
src/CleanArchitecture.Web/Program.cs
+7
-13
launchSettings.json
src/CleanArchitecture.Web/Properties/launchSettings.json
+27
-0
SeedData.cs
src/CleanArchitecture.Web/SeedData.cs
+30
-0
Startup.cs
src/CleanArchitecture.Web/Startup.cs
+6
-45
appsettings.json
src/CleanArchitecture.Web/appsettings.json
+3
-0
HomeControllerContactShould.cs
...ture.Tests/Integration/Web/HomeControllerContactShould.cs
+0
-1
No files found.
src/CleanArchitecture.Core/CleanArchitecture.Core.csproj
View file @
f2cb9398
...
@@ -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>
src/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj
View file @
f2cb9398
<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>
...
...
src/CleanArchitecture.Web/CleanArchitecture.Web.csproj
View file @
f2cb9398
<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>
...
...
src/CleanArchitecture.Web/Controllers/ToDoController.cs
View file @
f2cb9398
...
@@ -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
;
}
}
}
}
}
}
src/CleanArchitecture.Web/Program.cs
View file @
f2cb9398
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
();
}
}
}
}
}
src/CleanArchitecture.Web/Properties/launchSettings.json
0 → 100644
View file @
f2cb9398
{
"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
src/CleanArchitecture.Web/SeedData.cs
0 → 100644
View file @
f2cb9398
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
();
}
}
}
src/CleanArchitecture.Web/Startup.cs
View file @
f2cb9398
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
(
I
HostingEnvironment
env
)
public
Startup
(
I
Configuration
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
IConfiguration
Root
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"
));
...
...
src/CleanArchitecture.Web/appsettings.json
View file @
f2cb9398
{
{
"ConnectionStrings"
:
{
"DefaultConnection"
:
"Server=(localdb)
\\
v11.0;Database=cleanarchitecture;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging"
:
{
"Logging"
:
{
"IncludeScopes"
:
false
,
"IncludeScopes"
:
false
,
"LogLevel"
:
{
"LogLevel"
:
{
...
...
tests/CleanArchitecture.Tests/Integration/Web/HomeControllerContactShould.cs
View file @
f2cb9398
...
@@ -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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment