当前位置: 首页>>代码示例>>Java>>正文


Java MoneyBag类代码示例

本文整理汇总了Java中junit.samples.money.MoneyBag的典型用法代码示例。如果您正苦于以下问题:Java MoneyBag类的具体用法?Java MoneyBag怎么用?Java MoneyBag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MoneyBag类属于junit.samples.money包,在下文中一共展示了MoneyBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Before
public void setUp() {
    f12CHF = new Money(12, "CHF");
    f14CHF = new Money(14, "CHF");
    f7USD = new Money(7, "USD");
    f21USD = new Money(21, "USD");

    fMB1 = MoneyBag.create(f12CHF, f7USD);
    fMB2 = MoneyBag.create(f14CHF, f21USD);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:11,代码来源:MoneyTest.java

示例2: testBagMultiply

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testBagMultiply() {
    // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]}
    IMoney expected = MoneyBag.create(new Money(24, "CHF"), new Money(14, "USD"));
    assertEquals(expected, fMB1.multiply(2));
    assertEquals(fMB1, fMB1.multiply(1));
    assertTrue(fMB1.multiply(0).isZero());
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:9,代码来源:MoneyTest.java

示例3: testMoneyBagEquals

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testMoneyBagEquals() {
    assertTrue(!fMB1.equals(null));

    assertEquals(fMB1, fMB1);
    IMoney equal = MoneyBag.create(new Money(12, "CHF"), new Money(7, "USD"));
    assertTrue(fMB1.equals(equal));
    assertTrue(!fMB1.equals(f12CHF));
    assertTrue(!f12CHF.equals(fMB1));
    assertTrue(!fMB1.equals(fMB2));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:12,代码来源:MoneyTest.java

示例4: testNormalize3

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testNormalize3() {
    // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD]
    IMoney ms1 = MoneyBag.create(new Money(12, "CHF"), new Money(3, "USD"));
    Money expected = new Money(4, "USD");
    assertEquals(expected, fMB1.subtract(ms1));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:8,代码来源:MoneyTest.java

示例5: testBagNegate

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testBagNegate() {
    // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]}
    IMoney expected = MoneyBag.create(new Money(-12, "CHF"), new Money(-7, "USD"));
    assertEquals(expected, fMB1.negate());
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java

示例6: testBagSimpleAdd

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testBagSimpleAdd() {
    // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]}
    IMoney expected = MoneyBag.create(new Money(26, "CHF"), new Money(7, "USD"));
    assertEquals(expected, fMB1.add(f14CHF));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java

示例7: testBagSubtract

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testBagSubtract() {
    // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]}
    IMoney expected = MoneyBag.create(new Money(-2, "CHF"), new Money(-14, "USD"));
    assertEquals(expected, fMB1.subtract(fMB2));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java

示例8: testBagSumAdd

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testBagSumAdd() {
    // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]}
    IMoney expected = MoneyBag.create(new Money(26, "CHF"), new Money(28, "USD"));
    assertEquals(expected, fMB1.add(fMB2));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java

示例9: testIsZero

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testIsZero() {
    assertTrue(fMB1.subtract(fMB1).isZero());
    assertTrue(MoneyBag.create(new Money(0, "CHF"), new Money(0, "USD")).isZero());
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:6,代码来源:MoneyTest.java

示例10: testMixedSimpleAdd

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testMixedSimpleAdd() {
    // [12 CHF] + [7 USD] == {[12 CHF][7 USD]}
    IMoney expected = MoneyBag.create(f12CHF, f7USD);
    assertEquals(expected, f12CHF.add(f7USD));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java

示例11: testBagNotEquals

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testBagNotEquals() {
    IMoney bag = MoneyBag.create(f12CHF, f7USD);
    assertFalse(bag.equals(new Money(12, "DEM").add(f7USD)));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:6,代码来源:MoneyTest.java

示例12: testMoneyBagHash

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testMoneyBagHash() {
    IMoney equal = MoneyBag.create(new Money(12, "CHF"), new Money(7, "USD"));
    assertEquals(fMB1.hashCode(), equal.hashCode());
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:6,代码来源:MoneyTest.java

示例13: testSimplify

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testSimplify() {
    IMoney money = MoneyBag.create(new Money(26, "CHF"), new Money(28, "CHF"));
    assertEquals(new Money(54, "CHF"), money);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:6,代码来源:MoneyTest.java

示例14: testNormalize4

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testNormalize4() { // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD]
    IMoney ms1 = MoneyBag.create(new Money(12, "CHF"), new Money(3, "USD"));
    Money expected = new Money(-3, "USD");
    assertEquals(expected, f12CHF.subtract(ms1));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java

示例15: testSimpleBagAdd

import junit.samples.money.MoneyBag; //导入依赖的package包/类
@Test
public void testSimpleBagAdd() {
    // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]}
    IMoney expected = MoneyBag.create(new Money(26, "CHF"), new Money(7, "USD"));
    assertEquals(expected, f14CHF.add(fMB1));
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:7,代码来源:MoneyTest.java


注:本文中的junit.samples.money.MoneyBag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。