Skip to content

Commit 19ab741

Browse files
committed
Restructure project
1 parent 398dff6 commit 19ab741

15 files changed

+61
-74
lines changed

WealthKernel.ShoppingCart.sln

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WealthKernel.ShoppingCart", "src\WealthKernel.ShoppingCart.csproj", "{8419B160-5AF8-4F58-ADCC-46A7342B86A3}"
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WealthKernel.ShoppingCart", "src\WealthKernel.ShoppingCart\WealthKernel.ShoppingCart.csproj", "{8419B160-5AF8-4F58-ADCC-46A7342B86A3}"
44
EndProject
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WealthKernel.ShoppingCart.IntegrationTests", "test\WealthKernel.ShoppingCart.IntegrationTests\WealthKernel.ShoppingCart.IntegrationTests.csproj", "{F18825DF-FB5F-4B27-B8D2-A7322163E069}"
66
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WealthKernel.ShoppingCart.Data", "src\WealthKernel.ShoppingCart.Data\WealthKernel.ShoppingCart.Data.csproj", "{646CA955-A5D6-49B5-AB96-7D5837E0E29B}"
8+
EndProject
79
Global
810
GlobalSection(SolutionConfigurationPlatforms) = preSolution
911
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
1820
{F18825DF-FB5F-4B27-B8D2-A7322163E069}.Debug|Any CPU.Build.0 = Debug|Any CPU
1921
{F18825DF-FB5F-4B27-B8D2-A7322163E069}.Release|Any CPU.ActiveCfg = Release|Any CPU
2022
{F18825DF-FB5F-4B27-B8D2-A7322163E069}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{646CA955-A5D6-49B5-AB96-7D5837E0E29B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{646CA955-A5D6-49B5-AB96-7D5837E0E29B}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{646CA955-A5D6-49B5-AB96-7D5837E0E29B}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{646CA955-A5D6-49B5-AB96-7D5837E0E29B}.Release|Any CPU.Build.0 = Release|Any CPU
2127
EndGlobalSection
2228
EndGlobal

src/Models/CartItemInternal.cs

-9
This file was deleted.

src/Program.cs

-23
This file was deleted.

src/Data/ShoppingCartRepository.cs renamed to src/WealthKernel.ShoppingCart.Data/InMemoryCartItemsRepository.cs

+11-16
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,39 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using WealthKernel.ShoppingCart.Models;
5+
using WealthKernel.ShoppingCart.Data.Models;
66

77
namespace WealthKernel.ShoppingCart.Data
88
{
9-
public class ShoppingCartRepository
9+
public class InMemoryCartItemsRepository
1010
{
11-
private readonly ConcurrentDictionary<string,CartItemInternal> _items;
11+
private readonly ConcurrentDictionary<string, CartItem> _items;
1212

13-
public ShoppingCartRepository()
13+
public InMemoryCartItemsRepository()
1414
{
15-
_items = new ConcurrentDictionary<string, CartItemInternal>();
16-
}
17-
18-
public void AddItem(CartItemInternal item)
15+
_items = new ConcurrentDictionary<string, CartItem>();
16+
}
17+
18+
public void AddCartItem(CartItem item)
1919
{
2020
var added = _items.TryAdd(item.Id, item);
21-
21+
2222
if (!added)
2323
{
2424
throw new InvalidOperationException($"Item {item.Id} already exists!");
2525
}
2626
}
2727

28-
public CartItemInternal? GetItem(string id)
28+
public CartItem? GetCartItem(string id)
2929
{
3030
_items.TryGetValue(id, out var item);
3131
return item;
3232
}
3333

34-
public IList<CartItemInternal> SearchItems(string? id = null, string? name = null)
34+
public IList<CartItem> SearchCartItems(string? name = null)
3535
{
3636
var itemsQueryable = _items.Values.AsQueryable();
3737

38-
if (!string.IsNullOrEmpty(id))
39-
{
40-
itemsQueryable = itemsQueryable.Where(r => r.Id == id);
41-
}
42-
4338
if (!string.IsNullOrEmpty(name))
4439
{
4540
itemsQueryable = itemsQueryable.Where(r => r.Name == name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace WealthKernel.ShoppingCart.Data.Models
2+
{
3+
public class CartItem
4+
{
5+
public string Id { get; }
6+
7+
public string Name { get; }
8+
9+
public CartItem(string id, string name)
10+
{
11+
Id = id;
12+
Name = name;
13+
}
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
</PropertyGroup>
8+
9+
</Project>
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
3+
4+
namespace WealthKernel.ShoppingCart
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args) => CreateHostBuilder(args).Build().Run();
9+
10+
private static IHostBuilder CreateHostBuilder(string[] args) =>
11+
Host.CreateDefaultBuilder(args)
12+
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
13+
}
14+
}

src/Properties/launchSettings.json renamed to src/WealthKernel.ShoppingCart/Properties/launchSettings.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"profiles": {
33
"WealthKernel.ShoppingCart": {
44
"commandName": "Project",
5-
"launchBrowser": true,
65
"applicationUrl": "http://localhost:22222",
76
"environmentVariables": {
87
"ASPNETCORE_ENVIRONMENT": "Development"

src/ShoppingCartController.cs renamed to src/WealthKernel.ShoppingCart/ShoppingCartController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ namespace WealthKernel.ShoppingCart
55
[ApiController]
66
public class ShoppingCartController : ControllerBase
77
{
8-
98
}
109
}
File renamed without changes.

src/WealthKernel.ShoppingCart.csproj renamed to src/WealthKernel.ShoppingCart/WealthKernel.ShoppingCart.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<Nullable>enable</Nullable>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
<IsPackable>false</IsPackable>
68
</PropertyGroup>
79

810
</Project>
File renamed without changes.

src/appsettings.Development.json

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Net.Http;
21
using Microsoft.AspNetCore.Mvc.Testing;
32
using Xunit;
43

@@ -12,16 +11,5 @@ public ShoppingCartTests(WebApplicationFactory<Startup> factory)
1211
{
1312
_factory = factory;
1413
}
15-
16-
[Fact]
17-
public void First_Test()
18-
{
19-
var client = _factory.CreateClient();
20-
21-
// e.g.
22-
// client.PostAsJsonAsync("/some/url", new {})
23-
}
24-
25-
2614
}
2715
}

test/WealthKernel.ShoppingCart.IntegrationTests/WealthKernel.ShoppingCart.IntegrationTests.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
5+
<Nullable>enable</Nullable>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
67
<IsPackable>false</IsPackable>
78
</PropertyGroup>
89

@@ -17,7 +18,7 @@
1718
</ItemGroup>
1819

1920
<ItemGroup>
20-
<ProjectReference Include="..\..\src\WealthKernel.ShoppingCart.csproj" />
21+
<ProjectReference Include="..\..\src\WealthKernel.ShoppingCart\WealthKernel.ShoppingCart.csproj" />
2122
</ItemGroup>
2223

2324
</Project>

0 commit comments

Comments
 (0)