Skip to content

Commit ac146f4

Browse files
author
Carlos Cañizares Estévez
committed
Added Unit Test Project for services
1 parent d8a0d9b commit ac146f4

19 files changed

Lines changed: 696 additions & 75 deletions

File tree

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ services:
6262
- SpaClient=http://localhost:5104
6363
- ConnectionStrings__DefaultConnection=Server=sql.data;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word
6464
#- MvcClient=http://13.88.8.119:5100 #Remote: VM Needs to have public access at 5105.
65-
- MvcClient=http://localhost:5100 #Local: You need a entry in windows host file to run identity in local docker.
65+
#- MvcClient=http://localhost:5100 #Local: You need a entry in windows host file to run identity in local docker.
6666
- MvcClient=http://10.0.75.1:5100 #Local: You need to open windows firewall at range 5100-5105.
6767
ports:
6868
- "5105:5105"

eShopOnContainers.sln

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.UITests",
7373
EndProject
7474
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.Core", "src\Mobile\eShopOnContainers\eShopOnContainers.Core\eShopOnContainers.Core.csproj", "{67F9D3A8-F71E-4428-913F-C37AE82CDB24}"
7575
EndProject
76-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Application", "src\Services\Ordering\Ordering.Application\Ordering.Application.xproj", "{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}"
76+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UnitTest", "test\Services\UnitTest\UnitTest.xproj", "{7796F5D8-31FC-45A4-B673-19DE5BA194CF}"
7777
EndProject
7878
Global
7979
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -908,54 +908,54 @@ Global
908908
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x64.Build.0 = Release|Any CPU
909909
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x86.ActiveCfg = Release|Any CPU
910910
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x86.Build.0 = Release|Any CPU
911-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
912-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
913-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
914-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
915-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
916-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
917-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
918-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
919-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
920-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
921-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
922-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
923-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
924-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.Build.0 = Debug|Any CPU
925-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.ActiveCfg = Debug|Any CPU
926-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.Build.0 = Debug|Any CPU
927-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
928-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.Build.0 = Debug|Any CPU
929-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
930-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
931-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.ActiveCfg = Debug|Any CPU
932-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.Build.0 = Debug|Any CPU
933-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.ActiveCfg = Debug|Any CPU
934-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.Build.0 = Debug|Any CPU
935-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
936-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
937-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.ActiveCfg = Debug|Any CPU
938-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.Build.0 = Debug|Any CPU
939-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
940-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.Build.0 = Debug|Any CPU
941-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
942-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
943-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.ActiveCfg = Debug|Any CPU
944-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.Build.0 = Debug|Any CPU
945-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.ActiveCfg = Debug|Any CPU
946-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.Build.0 = Debug|Any CPU
947-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
948-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.Build.0 = Release|Any CPU
949-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.ActiveCfg = Release|Any CPU
950-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.Build.0 = Release|Any CPU
951-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.ActiveCfg = Release|Any CPU
952-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.Build.0 = Release|Any CPU
953-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
954-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
955-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.ActiveCfg = Release|Any CPU
956-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.Build.0 = Release|Any CPU
957-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.ActiveCfg = Release|Any CPU
958-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.Build.0 = Release|Any CPU
911+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
912+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
913+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
914+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
915+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
916+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
917+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
918+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
919+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
920+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
921+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
922+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
923+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
924+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|Any CPU.Build.0 = Debug|Any CPU
925+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|ARM.ActiveCfg = Debug|Any CPU
926+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|ARM.Build.0 = Debug|Any CPU
927+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
928+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|iPhone.Build.0 = Debug|Any CPU
929+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
930+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
931+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|x64.ActiveCfg = Debug|Any CPU
932+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|x64.Build.0 = Debug|Any CPU
933+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|x86.ActiveCfg = Debug|Any CPU
934+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.AppStore|x86.Build.0 = Debug|Any CPU
935+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
936+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
937+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|ARM.ActiveCfg = Debug|Any CPU
938+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|ARM.Build.0 = Debug|Any CPU
939+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|iPhone.ActiveCfg = Debug|Any CPU
940+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|iPhone.Build.0 = Debug|Any CPU
941+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
942+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
943+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|x64.ActiveCfg = Debug|Any CPU
944+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|x64.Build.0 = Debug|Any CPU
945+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|x86.ActiveCfg = Debug|Any CPU
946+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Debug|x86.Build.0 = Debug|Any CPU
947+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
948+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|Any CPU.Build.0 = Release|Any CPU
949+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|ARM.ActiveCfg = Release|Any CPU
950+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|ARM.Build.0 = Release|Any CPU
951+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|iPhone.ActiveCfg = Release|Any CPU
952+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|iPhone.Build.0 = Release|Any CPU
953+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
954+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
955+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x64.ActiveCfg = Release|Any CPU
956+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x64.Build.0 = Release|Any CPU
957+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x86.ActiveCfg = Release|Any CPU
958+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x86.Build.0 = Release|Any CPU
959959
EndGlobalSection
960960
GlobalSection(SolutionProperties) = preSolution
961961
HideSolutionNode = FALSE
@@ -990,6 +990,6 @@ Global
990990
{621E7211-58D0-45FD-9600-1CB490BD930E} = {EF0337F2-ED00-4643-89FD-EE10863F1870}
991991
{E3B18084-842C-4B80-8E4A-A7E588EC3137} = {B7B1D395-4E06-4036-BE86-C216756B9367}
992992
{67F9D3A8-F71E-4428-913F-C37AE82CDB24} = {778289CA-31F7-4464-8C2A-612EE846F8A7}
993-
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B}
993+
{7796F5D8-31FC-45A4-B673-19DE5BA194CF} = {EF0337F2-ED00-4643-89FD-EE10863F1870}
994994
EndGlobalSection
995995
EndGlobal

src/Services/Identity/eShopOnContainers.Identity/Configuration/Config.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
8282
RedirectUris = new List<string>
8383
{
8484
$"{clientsUrl["Mvc"]}/signin-oidc",
85-
"http://104.40.62.65:5100/signin-oidc"
85+
"http://104.40.62.65:5100/signin-oidc",
86+
"http://localhost:5100"
8687
},
8788
PostLogoutRedirectUris = new List<string>
8889
{

src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Api.Application.Commands;
44
using Api.Application.Queries;
55
using AspNetCore.Authorization;
6+
using Infrastructure.Services;
67
using MediatR;
78
using Microsoft.AspNetCore.Mvc;
89
using Models;
@@ -16,8 +17,9 @@ public class OrdersController : Controller
1617
{
1718
private readonly IMediator _mediator;
1819
private readonly IOrderQueries _orderQueries;
20+
private readonly IIdentityService _identityService;
1921

20-
public OrdersController(IMediator mediator, IOrderQueries orderQueries)
22+
public OrdersController(IMediator mediator, IOrderQueries orderQueries, IIdentityService identityService)
2123
{
2224
if (mediator == null)
2325
{
@@ -29,21 +31,24 @@ public OrdersController(IMediator mediator, IOrderQueries orderQueries)
2931
throw new ArgumentNullException(nameof(orderQueries));
3032
}
3133

34+
if (identityService == null)
35+
{
36+
throw new ArgumentException(nameof(identityService));
37+
}
38+
3239
_mediator = mediator;
3340
_orderQueries = orderQueries;
41+
_identityService = identityService;
3442
}
3543

3644
[Route("new")]
3745
[HttpPost]
3846
public async Task<IActionResult> AddOrder([FromBody]NewOrderRequest order)
3947
{
40-
if (order.CardExpiration == DateTime.MinValue)
41-
order.CardExpiration = DateTime.Now.AddYears(5);
42-
4348
if (order.CardTypeId == 0)
4449
order.CardTypeId = 1;
4550

46-
order.Buyer = GetUserName();
51+
order.Buyer = _identityService.GetUserIdentity();
4752

4853
var added = await _mediator.SendAsync(order);
4954
if (added)
@@ -86,17 +91,7 @@ public async Task<IActionResult> GetCardTypes()
8691

8792
return Ok(cardTypes);
8893
}
89-
90-
/// <summary>
91-
/// Returns the GUID corresponding to the Id of the authenticated user.
92-
/// </summary>
93-
/// <returns>GUID (string)</returns>
94-
string GetUserName()
95-
{
96-
return HttpContext.User.FindFirst("sub").Value;
97-
}
9894
}
99-
10095
}
10196

10297

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services
7+
{
8+
public interface IIdentityService
9+
{
10+
string GetUserIdentity();
11+
}
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+

2+
using Microsoft.AspNetCore.Http;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
8+
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services
9+
{
10+
public class IdentityService : IIdentityService
11+
{
12+
private IHttpContextAccessor _context;
13+
14+
public IdentityService(IHttpContextAccessor context)
15+
{
16+
if (context == null)
17+
{
18+
throw new ArgumentNullException(nameof(context));
19+
}
20+
21+
_context = context;
22+
}
23+
24+
public string GetUserIdentity()
25+
{
26+
return _context.HttpContext.User.FindFirst("sub").Value;
27+
}
28+
}
29+
}

src/Services/Ordering/Ordering.API/Startup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace Microsoft.eShopOnContainers.Services.Ordering.API
22
{
3+
using AspNetCore.Http;
34
using Autofac;
45
using Autofac.Extensions.DependencyInjection;
56
using Infrastructure;
67
using Infrastructure.AutofacModules;
78
using Infrastructure.Filters;
9+
using Infrastructure.Services;
810
using Microsoft.AspNetCore.Builder;
911
using Microsoft.AspNetCore.Hosting;
1012
using Microsoft.EntityFrameworkCore;
@@ -74,7 +76,10 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
7476
.AllowCredentials());
7577
});
7678

79+
// Add application services.
80+
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
7781
services.AddSingleton<IConfiguration>(this.Configuration);
82+
services.AddTransient<IIdentityService,IdentityService>();
7883

7984
services.AddOptions();
8085

src/Services/Ordering/Ordering.Application/Queries/OrderQueries.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
using System;
88
using System.Dynamic;
99
using System.Collections.Generic;
10+
using System.Linq;
1011

1112
public class OrderQueries
12-
:IOrderQueries
13+
: IOrderQueries
1314
{
1415
private string _connectionString = string.Empty;
1516

@@ -97,5 +98,31 @@ private dynamic MapOrderItems(dynamic result)
9798

9899
return order;
99100
}
101+
102+
//TODO/CCE: try to use this method instead actual.
103+
//private object MapOrderItems(dynamic result)
104+
//{
105+
// IEnumerable<dynamic> items = (result as System.Collections.IEnumerable).Cast<dynamic>();
106+
// var order = new
107+
// {
108+
// ordernumber = result[0].ordernumbe,
109+
// date = result[0].date,
110+
// status = result[0].status,
111+
// street = result[0].street,
112+
// city = result[0].city,
113+
// zipcode = result[0].zipcode,
114+
// country = result[0].country,
115+
// total = items.Select(r => (int)r.units * (int)r.unitprice).Sum(),
116+
// orderItems = items.Select(r => new
117+
// {
118+
// productname = r.productname,
119+
// units = r.units,
120+
// unitprice = r.unitprice,
121+
// pictureurl = r.pictureurl
122+
// })
123+
// };
124+
125+
// return order;
126+
//}
100127
}
101128
}

src/Web/WebMVC/Startup.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public Startup(IHostingEnvironment env)
3333
// builder.AddUserSecrets();
3434
//}
3535

36-
//builder.AddJsonFile("appsettings.override.json");
37-
//builder.AddEnvironmentVariables();
38-
3936
Configuration = builder.Build();
4037
}
4138

@@ -51,7 +48,7 @@ public void ConfigureServices(IServiceCollection services)
5148
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
5249

5350
services.AddTransient<ICatalogService, CatalogService>();
54-
services.AddSingleton<IOrderingService, OrderingService>(); //CCE: Once services are integrated, a singleton is not needed we can left transient.
51+
services.AddTransient<IOrderingService, OrderingService>();
5552
services.AddTransient<IBasketService, BasketService>();
5653
services.AddTransient<IIdentityParser<ApplicationUser>, IdentityParser>();
5754
}
@@ -86,9 +83,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
8683
var callBackUrl = Configuration.GetValue<string>("CallBackUrl");
8784
var log = loggerFactory.CreateLogger("identity");
8885

89-
log.LogDebug(identityUrl.ToString());
90-
log.LogDebug(callBackUrl.ToString());
91-
9286
var oidcOptions = new OpenIdConnectOptions
9387
{
9488
AuthenticationScheme = "oidc",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.eShopOnContainers.Services.Catalog.API.Controllers;
4+
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
5+
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
6+
using Moq;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Threading;
11+
using System.Threading.Tasks;
12+
using Xunit;
13+
14+
namespace UnitTest.Catalog
15+
{
16+
public class CatalogControllerTest
17+
{
18+
private readonly Mock<CatalogContext> _mockContext;
19+
private readonly Mock<IQueryable<CatalogItem>> _mockItems;
20+
public CatalogControllerTest()
21+
{
22+
_mockContext = new Mock<CatalogContext>();
23+
_mockItems = new Mock<IQueryable<CatalogItem>>();
24+
}
25+
26+
[Fact]
27+
public async Task Items_ReturnsOKObject_WhenItemsFound()
28+
{
29+
//CCE: TODO
30+
Assert.True(true);
31+
}
32+
33+
}
34+
}

0 commit comments

Comments
 (0)