-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCustomerTests03.java
54 lines (51 loc) · 1.85 KB
/
CustomerTests03.java
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
/*
* $
*
* Copyright (C) 2019 Cefalo AS.
* All Rights Reserved. No use, copying or distribution of this
* work may be made except in accordance with a valid license
* agreement from Cefalo AS. This notice must be included on all
* copies, modifications and derivatives of this work.
*/
package com.cefalo.tdd;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author <a href="mailto:[email protected]">Ferdous Mahmud Shaon</a>
* @author last modified by $
* @version $ $
*/
public class CustomerTests03 {
/*
* Customer has following properties:
* Name: name of the customer, String, Mandatory
*
* RewardPoints: the total reward points of a customer, default value: 0, integer
* value can only be set >=0, otherwise throws IllegalArgumentException
*
* purchaseGoods(int amount): increase the total RewardPoints count based on the following formula:
* total RewardPoints count += ceil(amount * 0.1)
* the amount cannot be <0, otherwise throw IllegalArgumentException
*
* redeemPoints(int points): decrease the total RewardPoints count by the given number of points
* if the given number of points < total RewardPoints count
* otherwise throw IllegalArgumentException
*
* */
@Test
public void testCustomerWithNameOnly() {
Customer customer = new Customer("Arnab");
assertEquals("Arnab", customer.getName());
}
@Test
public void testCustomerWithRewardPoints() {
Customer customer = new Customer("Arnab");
customer.setRewardPoints(100);
assertEquals(100, customer.getRewardPoints());
}
@Test
public void testCustomerWithDefaultRewardPoints() {
Customer customer = new Customer("Arnab");
assertEquals(0, customer.getRewardPoints());
}
}