-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoinTest.java
130 lines (109 loc) · 3.85 KB
/
CoinTest.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
/** Class that does JUnit testing for the Coin class
*
*
* @author AustinKRahmin
*
*/
class CoinTest {
Coin crytocurrency;
/** Method that sets up the CoinTest class for JUnit testing. Creates a cryptocurrency on the exchange Binance with a bid price of
* 3560 and a ask price of 3700.12
*
*
*/
@BeforeEach
public void setUp() {
crytocurrency = new Coin("Binance", "Bitcoin", 3560.00, 3700.12);
}
/** Test Purpose: Tests the basic functionality in order to retrieve the exchange. This method is significant because traders need to know
* where to buy and sell the currency if an arbitrage opportunity exists.
*
*
*/
@Test
void testGetExchange() {
assertEquals("Binance", crytocurrency.getExchange());
}
/** Test Purpose: Tests the basic functionality in order to retrieve the get the asset name.
* This method is important to traders because they need to know
* which currency to buy and sell the currency if an arbitrage opportunity exists.
*
*
*/
@Test
void testGetAsset() {
String test = crytocurrency.getAsset();
assertEquals("Bitcoin", test);
}
/** Test Purpose: Tests the basic functionality in order to retrieve the bid price.
* This method is important to traders because they need to know how much to sell the currency for. The bid price on an exchange
* is the price that traders will eventually sell the currency for. Therefore, this method is significant to traders because it allows them to
* calculate profit
*
*
*/
@Test
void testGetBidPrice() {
double test = crytocurrency.getBidPrice();
assertEquals(3560.00,test);
}
/** Test Purpose: Tests the basic functionality in order to retrieve the ask price.
* This method is important to traders because they need to know how much to sell the currency for. The bid price on an exchange
* is the price that traders will buy the currency for from an exchange.
* Therefore, this method is significant to traders because it allows them to
* calculate profit
*
*
*/
@Test
void testGetAskPrice() {
double test = crytocurrency.getAskPrice();
assertEquals(3700.12,test);
}
/** Test Purpose: Tests the basic functionality to set a currency's name.
* This method is important in accessing the API. Program must be able to read the API and construct the coin object in order to
* eventually conduct financial analysis on it.
*
*
*/
@Test
void testSetAsset() {
crytocurrency.setAsset("Ether");
assertEquals("Ether",crytocurrency.getAsset());
}
/** Test Purpose: Tests the basic functionality to set an exchange name.
* This method is important in accessing the API. Program must be able to read the API and construct the coin object in order to
* eventually conduct financial analysis on it.
*
*
*/
@Test
void testSetExchange() {
crytocurrency.setExchange("CoinBase");
assertEquals("CoinBase",crytocurrency.getExchange());
}
/** Test Purpose: Tests the basic functionality to set an ask price.
* This method is important in accessing the API. Program must be able to read the API and construct the coin object in order to
* eventually conduct financial analysis on it. Uses setter in order to do this.
*
*
*/
@Test
void testSetAskPrice() {
crytocurrency.setAsk(1245.2);
assertEquals(1245.2,crytocurrency.getAskPrice());
}
/** Test Purpose: Tests the basic functionality to set a bid price.
* This method is important in accessing the API. Program must be able to read the API and construct the coin object in order to
* eventually conduct financial analysis on it. Uses setter in order to read API.
*
*/
@Test
void testSetBidPrice() {
crytocurrency.setBid(1800.3);
assertEquals(1800.3,crytocurrency.getBidPrice());
}
}