Skip to content

Commit 60df7c7

Browse files
committed
Began work on ServerReports
1 parent f96e3b0 commit 60df7c7

File tree

14 files changed

+288
-88
lines changed

14 files changed

+288
-88
lines changed

POS.Domain/Abstract/IOrderProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace POS.Domain.Abstract
66
{
7-
public interface IOrderProcessor : IDisposable
7+
public interface IOrderProcessor : IGenericRepository<Order>
88
{
99
#region Public Properties
1010

POS.Domain/Abstract/IRepository.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

POS.Domain/POS.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<Reference Include="System.ComponentModel.DataAnnotations" />
4848
<Reference Include="System.Core" />
4949
<Reference Include="System.Data.Entity" />
50+
<Reference Include="System.Web.ApplicationServices" />
5051
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
5152
<Reference Include="System.Xml.Linq" />
5253
<Reference Include="System.Data.DataSetExtensions" />
@@ -60,7 +61,6 @@
6061
<Compile Include="Abstract\IGenericRepository.cs" />
6162
<Compile Include="Abstract\IOrderProcessor.cs" />
6263
<Compile Include="Abstract\IProductRepository.cs" />
63-
<Compile Include="Abstract\IRepository.cs" />
6464
<Compile Include="ApplicationService\CartApplicationService.cs" />
6565
<Compile Include="Model\Cart.cs" />
6666
<Compile Include="Model\Category.cs" />

POS.Infrastructure/EFRepository.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

POS.Infrastructure/EfOrderRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace POS.Infrastructure
88
{
9-
public class EfOrderRepository : IOrderProcessor
9+
public class EfOrderRepository : GenericRepository<EfDbContext, Order>, IOrderProcessor
1010
{
1111
#region Fields
1212

POS.Infrastructure/Membership/WebSecurity.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace POS.Infrastructure.Membership
99
{
10+
using POS.Domain.Abstract;
11+
1012
public sealed class WebSecurity
1113
{
1214
public static HttpContextBase Context

POS.Infrastructure/POS.Infrastructure.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
<Compile Include="EfEstablishmentRepository.cs" />
5353
<Compile Include="EfOrderRepository.cs" />
5454
<Compile Include="EfProductRepository.cs" />
55-
<Compile Include="EFRepository.cs" />
5655
<Compile Include="GenericRepository.cs" />
5756
<Compile Include="Membership\CodeFirstMembershipProvider.cs" />
5857
<Compile Include="Membership\CodeFirstRoleProvider.cs" />

POS.Tests/POS.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<Reference Include="WebActivator, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL" />
8080
</ItemGroup>
8181
<ItemGroup>
82+
<Compile Include="ServerReportControllerTest.cs" />
8283
<Compile Include="WebUi.Controllers\MembershipControllerTest.cs" />
8384
<Compile Include="WebUi.Controllers\CustomExtensions\ListExtensionTest.cs" />
8485
<Compile Include="WebUi.Controllers\EstablishmentManagerControllerTest.cs" />
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
using POS.Controllers;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System;
4+
5+
namespace POS.Tests
6+
{
7+
using System.Collections.Generic;
8+
using System.Diagnostics;
9+
using System.Linq;
10+
using System.Web.Mvc;
11+
12+
using Moq;
13+
14+
using POS.Domain.Abstract;
15+
using POS.Domain.Model;
16+
using POS.Models;
17+
18+
/// <summary>
19+
///This is a test class for ServerReportControllerTest and is intended
20+
///to contain all ServerReportControllerTest Unit Tests
21+
///</summary>
22+
[TestClass]
23+
public class ServerReportControllerTest
24+
{
25+
26+
#region Fields
27+
28+
private Mock<IOrderProcessor> _mockRepository;
29+
30+
#endregion
31+
32+
[TestInitialize]
33+
public void MyTestInitialize()
34+
{
35+
var mock = new Mock<IOrderProcessor>();
36+
mock.Setup(m => m.Orders).Returns(
37+
new[]
38+
{
39+
new Order
40+
{
41+
OrderDetails =
42+
new List<OrderDetail>()
43+
{
44+
new OrderDetail
45+
{
46+
OrderId = 1,
47+
Quantity = 2,
48+
ProductName = "Basketball",
49+
UnitPrice = 14,
50+
LineItemPromoId = 2
51+
},
52+
new OrderDetail
53+
{
54+
OrderId = 1,
55+
Quantity = 1,
56+
ProductName = "Tennis Racket",
57+
UnitPrice = 47,
58+
LineItemPromoId = 1
59+
},
60+
new OrderDetail
61+
{
62+
OrderId = 1,
63+
Quantity = 3,
64+
ProductName = "Tennis Ball",
65+
UnitPrice = 6
66+
}
67+
},
68+
EstablishmentId = 1,
69+
TotalCost = (decimal)62.5,
70+
SalesTax = (decimal)5.15625,
71+
CustomerName = "Albert",
72+
ServerId = 2,
73+
ServerTip = (decimal)1.50,
74+
TimeProcessed = DateTime.Now.AddHours(-3.00)
75+
},
76+
new Order
77+
{
78+
OrderDetails =
79+
new List<OrderDetail>()
80+
{
81+
new OrderDetail
82+
{
83+
OrderId = 2,
84+
Quantity = 2,
85+
ProductName = "Basketball",
86+
UnitPrice = 14
87+
},
88+
new OrderDetail
89+
{
90+
OrderId = 2,
91+
Quantity = 1,
92+
ProductName = "Tennis Racket",
93+
UnitPrice = 47
94+
},
95+
new OrderDetail
96+
{
97+
OrderId = 2,
98+
Quantity = 3,
99+
ProductName = "Tennis Ball",
100+
UnitPrice = 6
101+
},
102+
},
103+
EstablishmentId = 1,
104+
TotalCost = 93,
105+
SalesTax = (decimal)7.6725,
106+
CustomerName = "Henry",
107+
ServerId = 3,
108+
ServerTip = (decimal)2.25,
109+
TimeProcessed = DateTime.Now
110+
},
111+
new Order
112+
{
113+
OrderDetails =
114+
new List<OrderDetail>()
115+
{
116+
new OrderDetail
117+
{
118+
OrderId = 3,
119+
Quantity = 1,
120+
ProductName = "Basketball",
121+
UnitPrice = 14
122+
}
123+
},
124+
EstablishmentId = 1,
125+
TotalCost = 14,
126+
SalesTax = (decimal)1.155,
127+
CustomerName = "Thomas",
128+
ServerId = 4,
129+
ServerTip = (decimal)3.76,
130+
TimeProcessed = DateTime.Now.AddHours(-0.50)
131+
},
132+
}.AsQueryable());
133+
_mockRepository = mock;
134+
}
135+
136+
/// I need total tips for the day
137+
/// I need Average Tips / Server
138+
/// Average Transactions / Server
139+
/// Number of Servers for time period
140+
141+
/// <summary>
142+
/// Index calculates the total amount of tips for for all orders
143+
/// </summary>
144+
[TestMethod]
145+
public void TotalAmountOfTipsForAllOrders()
146+
{
147+
// Arrange
148+
var controller = new ServerReportController(_mockRepository.Object);
149+
ServerReportIndexViewModel test = new ServerReportIndexViewModel{TotalTips = (decimal)7.51};
150+
// Action
151+
ViewResult result = controller.Index();
152+
var viewModel = (ServerReportIndexViewModel)result.ViewData.Model;
153+
// Assert
154+
Assert.AreEqual(test.TotalTips, viewModel.TotalTips);
155+
}
156+
157+
}
158+
}

POS/App_Start/NinjectWebCommon.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace POS.App_Start
1717
using Ninject.Web.Common;
1818

1919
using POS.Controllers;
20+
using POS.Infrastructure.Membership;
2021

2122
public static class NinjectWebCommon
2223
{

0 commit comments

Comments
 (0)