Browse Source

SPA: fixes in some components

pull/49/merge
Carlos Cañizares Estévez 8 years ago
parent
commit
4ae905b13c
7 changed files with 10 additions and 107 deletions
  1. +0
    -51
      eShopOnContainers.sln
  2. +1
    -0
      src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/basket/basket.component.ts
  3. +1
    -2
      src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/orders/orders-new/orders-new.component.html
  4. +3
    -0
      src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/orders/orders.service.ts
  5. +1
    -0
      src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/shared/models/order.model.ts
  6. +0
    -34
      test/Services/UnitTest/Catalog/CatalogControllertest.cs
  7. +4
    -20
      test/Services/UnitTest/Ordering/Controllers/OrderControllerTest.cs

+ 0
- 51
eShopOnContainers.sln View File

@ -75,8 +75,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.Core", "s
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UnitTest", "test\Services\UnitTest\UnitTest.xproj", "{7796F5D8-31FC-45A4-B673-19DE5BA194CF}" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UnitTest", "test\Services\UnitTest\UnitTest.xproj", "{7796F5D8-31FC-45A4-B673-19DE5BA194CF}"
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Application", "src\Services\Ordering\Ordering.Application\Ordering.Application.xproj", "{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -958,54 +956,6 @@ Global
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x64.Build.0 = Release|Any CPU {7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x64.Build.0 = Release|Any CPU
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x86.ActiveCfg = Release|Any CPU {7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x86.ActiveCfg = Release|Any CPU
{7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x86.Build.0 = Release|Any CPU {7796F5D8-31FC-45A4-B673-19DE5BA194CF}.Release|x86.Build.0 = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.ActiveCfg = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.Build.0 = Debug|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.Build.0 = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.ActiveCfg = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.Build.0 = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.ActiveCfg = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.Build.0 = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.ActiveCfg = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.Build.0 = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.ActiveCfg = Release|Any CPU
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1041,6 +991,5 @@ Global
{E3B18084-842C-4B80-8E4A-A7E588EC3137} = {B7B1D395-4E06-4036-BE86-C216756B9367} {E3B18084-842C-4B80-8E4A-A7E588EC3137} = {B7B1D395-4E06-4036-BE86-C216756B9367}
{67F9D3A8-F71E-4428-913F-C37AE82CDB24} = {778289CA-31F7-4464-8C2A-612EE846F8A7} {67F9D3A8-F71E-4428-913F-C37AE82CDB24} = {778289CA-31F7-4464-8C2A-612EE846F8A7}
{7796F5D8-31FC-45A4-B673-19DE5BA194CF} = {EF0337F2-ED00-4643-89FD-EE10863F1870} {7796F5D8-31FC-45A4-B673-19DE5BA194CF} = {EF0337F2-ED00-4643-89FD-EE10863F1870}
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

+ 1
- 0
src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/basket/basket.component.ts View File

@ -35,6 +35,7 @@ export class BasketComponent implements OnInit {
} }
private calculateTotalPrice() { private calculateTotalPrice() {
this.totalPrice = 0;
this.basket.items.forEach(item => { this.basket.items.forEach(item => {
this.totalPrice += (item.unitPrice * item.quantity) this.totalPrice += (item.unitPrice * item.quantity)
}); });


+ 1
- 2
src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/orders/orders-new/orders-new.component.html View File

@ -113,8 +113,7 @@
<td> <td>
<div class="cart-total-value"> <div class="cart-total-value">
<div class="cart-total-label"><span>TOTAL</span></div> <div class="cart-total-label"><span>TOTAL</span></div>
<span>$ 29,00</span>
<input type="hidden" value="29,00" name="Total">
<span>{{order.total}}</span>
</div> </div>
</td> </td>
</tr> </tr>


+ 3
- 0
src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/orders/orders.service.ts View File

@ -62,6 +62,7 @@ export class OrdersService {
order.cardsecuritynumber = identityInfo.card_security_number; order.cardsecuritynumber = identityInfo.card_security_number;
order.cardtypeid = identityInfo.card_type; order.cardtypeid = identityInfo.card_type;
order.cardholdername = identityInfo.card_holder; order.cardholdername = identityInfo.card_holder;
order.total = 0;
//basket data mapping: //basket data mapping:
order.orderItems = new Array<IOrderItem>(); order.orderItems = new Array<IOrderItem>();
@ -74,6 +75,8 @@ export class OrdersService {
item.unitprice = x.unitPrice; item.unitprice = x.unitPrice;
item.units = x.quantity; item.units = x.quantity;
order.total += (item.unitprice * item.units);
order.orderItems.push(item); order.orderItems.push(item);
}); });


+ 1
- 0
src/Web/WebSPA/eShopOnContainers.WebSPA/Client/modules/shared/models/order.model.ts View File

@ -14,5 +14,6 @@ export interface IOrder {
cardtypeid: number; cardtypeid: number;
buyer: string; buyer: string;
ordernumber: string, ordernumber: string,
total: number,
orderItems: IOrderItem[]; orderItems: IOrderItem[];
} }

+ 0
- 34
test/Services/UnitTest/Catalog/CatalogControllertest.cs View File

@ -1,34 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Catalog.API.Controllers;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace UnitTest.Catalog
{
public class CatalogControllerTest
{
private readonly Mock<CatalogContext> _mockContext;
private readonly Mock<IQueryable<CatalogItem>> _mockItems;
public CatalogControllerTest()
{
_mockContext = new Mock<CatalogContext>();
_mockItems = new Mock<IQueryable<CatalogItem>>();
}
[Fact]
public async Task Items_ReturnsOKObject_WhenItemsFound()
{
//CCE: TODO
Assert.True(true);
}
}
}

+ 4
- 20
test/Services/UnitTest/Ordering/Controllers/OrderControllerTest.cs View File

@ -17,6 +17,7 @@ namespace UnitTest.Ordering.Controllers
private readonly Mock<IMediator> _mediatorMock; private readonly Mock<IMediator> _mediatorMock;
private readonly Mock<IIdentityService> _identityMock; private readonly Mock<IIdentityService> _identityMock;
private readonly Mock<IOrderQueries> _queriesMock; private readonly Mock<IOrderQueries> _queriesMock;
private readonly string _userIdentity;
public OrderControllerTest() public OrderControllerTest()
{ {
@ -24,6 +25,7 @@ namespace UnitTest.Ordering.Controllers
_mediatorMock = new Mock<IMediator>(); _mediatorMock = new Mock<IMediator>();
_identityMock = new Mock<IIdentityService>(); _identityMock = new Mock<IIdentityService>();
_queriesMock = new Mock<IOrderQueries>(); _queriesMock = new Mock<IOrderQueries>();
_userIdentity = Guid.NewGuid().ToString();
} }
[Fact] [Fact]
@ -47,25 +49,6 @@ namespace UnitTest.Ordering.Controllers
Assert.IsType<BadRequestResult>(badRequestResult); Assert.IsType<BadRequestResult>(badRequestResult);
} }
[Fact]
public async Task AddOrder_ReturnsOK_WhenPersistenceOperationSucceed()
{
// Arrange
_mediatorMock.Setup(mediator => mediator.SendAsync(OrderFakeNotExpired()))
.Returns(Task.FromResult(true));
_identityMock.Setup(identity => identity.GetUserIdentity())
.Returns(Guid.NewGuid().ToString());
var controller = new OrdersController(_mediatorMock.Object, _queriesMock.Object, _identityMock.Object);
// Act
var badRequestResult = await controller.AddOrder(OrderFakeNotExpired());
// Assert
Assert.IsType<BadRequestResult>(badRequestResult);
}
[Fact] [Fact]
public async Task GetOrder_ReturnsNotFound_WhenItemNotFound() public async Task GetOrder_ReturnsNotFound_WhenItemNotFound()
{ {
@ -136,7 +119,8 @@ namespace UnitTest.Ordering.Controllers
return new NewOrderRequest() return new NewOrderRequest()
{ {
CardTypeId = 1, CardTypeId = 1,
CardExpiration = DateTime.Now.AddYears(1)
CardExpiration = new DateTime(2020, 12, 12),
Buyer = _userIdentity
}; };
} }


Loading…
Cancel
Save