Skip to content

Commit 38fd965

Browse files
committed
Merge branch 'order-processflow-redesign' of https://github.com/dotnet-architecture/eShopOnContainers into order-processflow-redesign
2 parents 07f3eb4 + e4c8462 commit 38fd965

5 files changed

Lines changed: 140 additions & 152 deletions

File tree

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,13 @@ private void ConfigureEventBus(IApplicationBuilder app)
176176
{
177177
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
178178

179-
eventBus.Subscribe<UserCheckoutAcceptedIntegrationEvent,IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>(
180-
() => app.ApplicationServices.GetRequiredService<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>());
179+
eventBus.Subscribe<UserCheckoutAcceptedIntegrationEvent,IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>();
181180

182-
eventBus.Subscribe<ConfirmGracePeriodCommandMsg, IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>>
183-
(() => app.ApplicationServices.GetRequiredService<IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>>());
181+
eventBus.Subscribe<ConfirmGracePeriodCommandMsg, IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>>();
184182

185-
eventBus.Subscribe<OrderStockConfirmedIntegrationEvent, OrderStockConfirmedIntegrationEventHandler>
186-
(() => app.ApplicationServices.GetRequiredService<OrderStockConfirmedIntegrationEventHandler>());
183+
eventBus.Subscribe<OrderStockConfirmedIntegrationEvent, OrderStockConfirmedIntegrationEventHandler>();
187184

188-
eventBus.Subscribe<OrderStockNotConfirmedIntegrationEvent, OrderStockNotConfirmedIntegrationEventHandler>
189-
(() => app.ApplicationServices.GetRequiredService<OrderStockNotConfirmedIntegrationEventHandler>());
185+
eventBus.Subscribe<OrderStockNotConfirmedIntegrationEvent, OrderStockNotConfirmedIntegrationEventHandler>();
190186
}
191187

192188
protected virtual void ConfigureAuth(IApplicationBuilder app)

test/Services/FunctionalTests/Services/Ordering/OrderingScenarios.cs

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,66 +13,64 @@
1313

1414
namespace FunctionalTests.Services.Ordering
1515
{
16-
public class OrderingScenarios : OrderingScenariosBase
17-
{
18-
[Fact]
19-
public async Task Create_order_and_return_the_order_by_id()
20-
{
21-
using (var server = CreateServer())
22-
{
23-
var client = server.CreateIdempotentClient();
16+
//public class OrderingScenarios : OrderingScenariosBase
17+
//{
18+
// [Fact]
19+
// public async Task Create_order_and_return_the_order_by_id()
20+
// {
21+
// using (var server = CreateServer())
22+
// {
23+
// var client = server.CreateIdempotentClient();
2424

25-
// GIVEN an order is created
26-
await client.PostAsync(Post.AddNewOrder, new StringContent(BuildOrder(), UTF8Encoding.UTF8, "application/json"));
25+
// // GIVEN an order is created
26+
// await client.PostAsync(Post.AddNewOrder, new StringContent(BuildOrder(), UTF8Encoding.UTF8, "application/json"));
2727

28-
var ordersResponse = await client.GetAsync(Get.Orders);
29-
var responseBody = await ordersResponse.Content.ReadAsStringAsync();
30-
var orders = JsonConvert.DeserializeObject<List<Order>>(responseBody);
31-
string orderId = orders.OrderByDescending(o => o.Date).First().OrderNumber;
28+
// var ordersResponse = await client.GetAsync(Get.Orders);
29+
// var responseBody = await ordersResponse.Content.ReadAsStringAsync();
30+
// var orders = JsonConvert.DeserializeObject<List<Order>>(responseBody);
31+
// string orderId = orders.OrderByDescending(o => o.Date).First().OrderNumber;
3232

33-
//WHEN we request the order bit its id
34-
var order= await client.GetAsync(Get.OrderBy(int.Parse(orderId)));
35-
var orderBody = await order.Content.ReadAsStringAsync();
36-
var result = JsonConvert.DeserializeObject<Order>(orderBody);
33+
// //WHEN we request the order bit its id
34+
// var order= await client.GetAsync(Get.OrderBy(int.Parse(orderId)));
35+
// var orderBody = await order.Content.ReadAsStringAsync();
36+
// var result = JsonConvert.DeserializeObject<Order>(orderBody);
3737

38-
//THEN the requested order is returned
39-
Assert.Equal(orderId, result.OrderNumber);
40-
Assert.Equal("inprocess", result.Status);
41-
Assert.Equal(1, result.OrderItems.Count);
42-
Assert.Equal(10, result.OrderItems[0].UnitPrice);
43-
}
44-
}
38+
// //THEN the requested order is returned
39+
// Assert.Equal(orderId, result.OrderNumber);
40+
// Assert.Equal("inprocess", result.Status);
41+
// Assert.Equal(1, result.OrderItems.Count);
42+
// Assert.Equal(10, result.OrderItems[0].UnitPrice);
43+
// }
44+
// }
4545

46-
string BuildOrder()
47-
{
48-
List<OrderItemDTO> orderItemsList = new List<OrderItemDTO>();
49-
orderItemsList.Add(new OrderItemDTO()
50-
{
51-
ProductId = 1,
52-
Discount = 8M,
53-
UnitPrice = 10,
54-
Units = 1,
55-
ProductName = "Some name"
56-
}
57-
);
46+
// string BuildOrder()
47+
// {
48+
// List<BasketItem> orderItemsList = new List<BasketItem>();
49+
// orderItemsList.Add(new BasketItem()
50+
// {
51+
// ProductId = "1",
52+
// Discount = 8M,
53+
// UnitPrice = 10,
54+
// Units = 1,
55+
// ProductName = "Some name"
56+
// }
57+
// );
5858

59-
var order = new CreateOrderCommand(
60-
orderItemsList,
61-
cardExpiration: DateTime.UtcNow.AddYears(1),
62-
cardNumber: "5145-555-5555",
63-
cardHolderName: "Jhon Senna",
64-
cardSecurityNumber: "232",
65-
cardTypeId: 1,
66-
city: "Redmon",
67-
country: "USA",
68-
state: "WA",
69-
street: "One way",
70-
zipcode: "zipcode",
71-
paymentId: 1,
72-
buyerId: 3
73-
);
59+
// var order = new CreateOrderCommand(
60+
// orderItemsList,
61+
// cardExpiration: DateTime.UtcNow.AddYears(1),
62+
// cardNumber: "5145-555-5555",
63+
// cardHolderName: "Jhon Senna",
64+
// cardSecurityNumber: "232",
65+
// cardTypeId: 1,
66+
// city: "Redmon",
67+
// country: "USA",
68+
// state: "WA",
69+
// street: "One way",
70+
// zipcode: "zipcode"
71+
// );
7472

75-
return JsonConvert.SerializeObject(order);
76-
}
77-
}
73+
// return JsonConvert.SerializeObject(order);
74+
// }
75+
//}
7876
}

test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs

Lines changed: 81 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -16,99 +16,97 @@
1616
public class OrderingScenarios
1717
: OrderingScenarioBase
1818
{
19-
[Fact]
20-
public async Task Get_get_all_stored_orders_and_response_ok_status_code()
21-
{
22-
using (var server = CreateServer())
23-
{
24-
var response = await server.CreateClient()
25-
.GetAsync(Get.Orders);
19+
// [Fact]
20+
// public async Task Get_get_all_stored_orders_and_response_ok_status_code()
21+
// {
22+
// using (var server = CreateServer())
23+
// {
24+
// var response = await server.CreateClient()
25+
// .GetAsync(Get.Orders);
2626

27-
response.EnsureSuccessStatusCode();
28-
}
29-
}
27+
// response.EnsureSuccessStatusCode();
28+
// }
29+
// }
3030

31-
[Fact]
32-
public async Task AddNewOrder_add_new_order_and_response_ok_status_code()
33-
{
34-
using (var server = CreateServer())
35-
{
36-
var content = new StringContent(BuildOrder(), UTF8Encoding.UTF8, "application/json");
37-
var response = await server.CreateIdempotentClient()
38-
.PostAsync(Post.AddNewOrder, content);
31+
// [Fact]
32+
// public async Task AddNewOrder_add_new_order_and_response_ok_status_code()
33+
// {
34+
// using (var server = CreateServer())
35+
// {
36+
// var content = new StringContent(BuildOrder(), UTF8Encoding.UTF8, "application/json");
37+
// var response = await server.CreateIdempotentClient()
38+
// .PostAsync(Post.AddNewOrder, content);
3939

40-
response.EnsureSuccessStatusCode();
41-
}
42-
}
40+
// response.EnsureSuccessStatusCode();
41+
// }
42+
// }
4343

44-
[Fact]
45-
public async Task AddNewOrder_response_bad_request_if_card_expiration_is_invalid()
46-
{
47-
using (var server = CreateServer())
48-
{
49-
var content = new StringContent(BuildOrderWithInvalidExperationTime(), UTF8Encoding.UTF8, "application/json");
44+
// [Fact]
45+
// public async Task AddNewOrder_response_bad_request_if_card_expiration_is_invalid()
46+
// {
47+
// using (var server = CreateServer())
48+
// {
49+
// var content = new StringContent(BuildOrderWithInvalidExperationTime(), UTF8Encoding.UTF8, "application/json");
5050

51-
var response = await server.CreateIdempotentClient()
52-
.PostAsync(Post.AddNewOrder, content);
51+
// var response = await server.CreateIdempotentClient()
52+
// .PostAsync(Post.AddNewOrder, content);
5353

54-
Assert.True(response.StatusCode == System.Net.HttpStatusCode.BadRequest);
55-
}
56-
}
54+
// Assert.True(response.StatusCode == System.Net.HttpStatusCode.BadRequest);
55+
// }
56+
// }
5757

58-
//public CreateOrderCommand(string city, string street, string state, string country, string zipcode,
59-
// string cardNumber, string cardHolderName, DateTime cardExpiration,
60-
// string cardSecurityNumber, int cardTypeId, int paymentId, int buyerId) : this()
58+
// //public CreateOrderCommand(string city, string street, string state, string country, string zipcode,
59+
// // string cardNumber, string cardHolderName, DateTime cardExpiration,
60+
// // string cardSecurityNumber, int cardTypeId, int paymentId, int buyerId) : this()
6161

62-
string BuildOrder()
63-
{
64-
List<OrderItemDTO> orderItemsList = new List<OrderItemDTO>();
65-
orderItemsList.Add(new OrderItemDTO()
66-
{
67-
ProductId = 1,
68-
Discount = 10M,
69-
UnitPrice = 10,
70-
Units = 1,
71-
ProductName = "Some name"
72-
}
73-
);
62+
// string BuildOrder()
63+
// {
64+
// List<OrderItemDTO> orderItemsList = new List<OrderItemDTO>();
65+
// orderItemsList.Add(new OrderItemDTO()
66+
// {
67+
// ProductId = 1,
68+
// Discount = 10M,
69+
// UnitPrice = 10,
70+
// Units = 1,
71+
// ProductName = "Some name"
72+
// }
73+
// );
7474

75-
var order = new CreateOrderCommand(
76-
orderItemsList,
77-
cardExpiration: DateTime.UtcNow.AddYears(1),
78-
cardNumber: "5145-555-5555",
79-
cardHolderName: "Jhon Senna",
80-
cardSecurityNumber: "232",
81-
cardTypeId: 1,
82-
city: "Redmon",
83-
country: "USA",
84-
state: "WA",
85-
street: "One way",
86-
zipcode: "zipcode",
87-
paymentId: 1,
88-
buyerId: 1
89-
);
75+
// var order = new CreateOrderCommand(
76+
// orderItemsList,
77+
// cardExpiration: DateTime.UtcNow.AddYears(1),
78+
// cardNumber: "5145-555-5555",
79+
// cardHolderName: "Jhon Senna",
80+
// cardSecurityNumber: "232",
81+
// cardTypeId: 1,
82+
// city: "Redmon",
83+
// country: "USA",
84+
// state: "WA",
85+
// street: "One way",
86+
// zipcode: "zipcode"
87+
// );
9088

91-
return JsonConvert.SerializeObject(order);
92-
}
93-
string BuildOrderWithInvalidExperationTime()
94-
{
95-
var order = new CreateOrderCommand(
96-
null,
97-
cardExpiration: DateTime.UtcNow.AddYears(-1),
98-
cardNumber: "5145-555-5555",
99-
cardHolderName: "Jhon Senna",
100-
cardSecurityNumber: "232",
101-
cardTypeId: 1,
102-
city: "Redmon",
103-
country: "USA",
104-
state: "WA",
105-
street: "One way",
106-
zipcode: "zipcode",
107-
buyerId: 1,
108-
paymentId:1
109-
);
89+
// return JsonConvert.SerializeObject(order);
90+
// }
91+
// string BuildOrderWithInvalidExperationTime()
92+
// {
93+
// var order = new CreateOrderCommand(
94+
// null,
95+
// cardExpiration: DateTime.UtcNow.AddYears(-1),
96+
// cardNumber: "5145-555-5555",
97+
// cardHolderName: "Jhon Senna",
98+
// cardSecurityNumber: "232",
99+
// cardTypeId: 1,
100+
// city: "Redmon",
101+
// country: "USA",
102+
// state: "WA",
103+
// street: "One way",
104+
// zipcode: "zipcode",
105+
// buyerId: 1,
106+
// paymentId:1
107+
// );
110108

111-
return JsonConvert.SerializeObject(order);
112-
}
109+
// return JsonConvert.SerializeObject(order);
110+
// }
113111
}
114112
}

test/Services/UnitTest/Ordering/Application/IdentifierCommandHandlerTest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ private CreateOrderCommand FakeOrderRequest(Dictionary<string, object> args = nu
8080
cardExpiration: args != null && args.ContainsKey("cardExpiration") ? (DateTime)args["cardExpiration"] : DateTime.MinValue,
8181
cardSecurityNumber: args != null && args.ContainsKey("cardSecurityNumber") ? (string)args["cardSecurityNumber"] : "123",
8282
cardHolderName: args != null && args.ContainsKey("cardHolderName") ? (string)args["cardHolderName"] : "XXX",
83-
cardTypeId: args != null && args.ContainsKey("cardTypeId") ? (int)args["cardTypeId"] : 0,
84-
paymentId: args != null && args.ContainsKey("paymentId") ? (int)args["paymentId"] : 0,
85-
buyerId: args != null && args.ContainsKey("buyerId") ? (int)args["buyerId"] : 0);
83+
cardTypeId: args != null && args.ContainsKey("cardTypeId") ? (int)args["cardTypeId"] : 0);
8684
}
8785
}
8886
}

test/Services/UnitTest/Ordering/Application/NewOrderCommandHandlerTest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ private CreateOrderCommand FakeOrderRequestWithBuyer(Dictionary<string, object>
8282
cardExpiration: args != null && args.ContainsKey("cardExpiration") ? (DateTime)args["cardExpiration"] : DateTime.MinValue,
8383
cardSecurityNumber: args != null && args.ContainsKey("cardSecurityNumber") ? (string)args["cardSecurityNumber"] : "123",
8484
cardHolderName: args != null && args.ContainsKey("cardHolderName") ? (string)args["cardHolderName"] : "XXX",
85-
cardTypeId: args != null && args.ContainsKey("cardTypeId") ? (int)args["cardTypeId"] : 0,
86-
paymentId: args != null && args.ContainsKey("paymentId") ? (int)args["paymentId"] : 0,
87-
buyerId: args != null && args.ContainsKey("buyerId") ? (int)args["buyerId"] : 0);
85+
cardTypeId: args != null && args.ContainsKey("cardTypeId") ? (int)args["cardTypeId"] : 0);
8886
}
8987
}
9088
}

0 commit comments

Comments
 (0)