-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRestaurantSpec.scala
More file actions
74 lines (48 loc) · 2.99 KB
/
Copy pathRestaurantSpec.scala
File metadata and controls
74 lines (48 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package restaurant
import com.restaurant.{Good, Restaurant}
import org.scalatest._
class RestaurantSpec extends FlatSpec with Matchers {
"calculateServiceCharge" should
"calculate Accurately the amount of charges to add to a the total good given the list of goods that contains food" in {
val restaurant = new Restaurant()
val goods = List(Good("Food",true,"cheese - Sandwch",2.00),Good("Drink",true,"cofee",1.00),Good("Food",true,"Steak - sandwich",4.50),Good("Drink", false, "Cola - cold", 0.50))
val serviceChargeWithFood = restaurant.calculateServiceCharge(goods,20,10)
serviceChargeWithFood should be(1.6 )
}
"calculateServiceCharge" should
"calculate Accurately the amount of charges to add to a the total good given the list of goods that doesnt contains food" in {
val restaurant = new Restaurant()
val goods = List(Good("Drink", false, "Cola - Cold", 0.50), Good("Drink", true, "cofee", 1.00), Good("Drink", false, "Cola - cold", 0.50))
val serviceChargeWithoutFood = restaurant.calculateServiceCharge(goods, 20, 10)
serviceChargeWithoutFood should be(0.0)
}
"calculateServiceCharge" should
"calculate Accurately the amount of charges to add to a the total good given the list and should never default the max service charge to $20" in {
val restaurant = new Restaurant()
val goods = List(Good("Food",true,"cheese - Sandwch",2000.09),Good("Drink",true,"cofee",200.0),Good("Food",false,"Steak - sandwich",100.0))
val serviceChargeWithoutFood = restaurant.calculateServiceCharge(goods, 20, 10)
serviceChargeWithoutFood should be(20.0)
}
"Restaurant.total" should
"return the total bill of of what was consumed without any sundry charges..LOL when there isnt any food in the order" in {
val restaurant = new Restaurant()
val goods = List(Good("Drink", false, "Cola - Cold", 0.50), Good("Drink", true, "cofee", 1.00), Good("Drink", false, "Cola - cold", 0.50))
val total = restaurant.total(goods)
total should be(2)
}
"Restaurant.total" should
"return the total bill of of what was consumed with charges ..LOL but the charges shouldnt be more than 20 when there is food in the order" in {
val restaurant = new Restaurant()
val goods = List(Good("Food",true,"cheese - Sandwch",2000.09),Good("Drink",true,"cofee",200.0),Good("Food",false,"Steak - sandwich",100.0))
val total = restaurant.total(goods)
total should be(2320.09)
}
"Restaurant.resolveInput" should
"return a structured list of goods" in {
val restaurant = new Restaurant()
val rawGoods = List("Coffee" ,"Cheese Sandwich","Cola", "Steak Sandwich" )
val resolved = restaurant.resolveInput(rawGoods)
val goods = List(Good("Drink",true,"Coffee",1.00),Good("Food",true,"Cheese Sandwich",2.00),Good("Drink",false,"Cola",0.50),Good("Food",false,"Steak Sandwich",4.50))
resolved should equal(goods)
}
}