本文整理汇总了C#中NUnit.Samples.Money.MoneyBag类的典型用法代码示例。如果您正苦于以下问题:C# MoneyBag类的具体用法?C# MoneyBag怎么用?C# MoneyBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MoneyBag类属于NUnit.Samples.Money命名空间,在下文中一共展示了MoneyBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BagNegate
public void BagNegate()
{
// {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]}
Money[] bag= { new Money(-12, "CHF"), new Money(-7, "USD") };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, fMB1.Negate());
}
示例2: BagSubtract
public void BagSubtract()
{
// {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]}
Money[] bag= { new Money(-2, "CHF"), new Money(-14, "USD") };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, fMB1.Subtract(fMB2));
}
示例3: BagSimpleAdd
public void BagSimpleAdd()
{
// {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]}
Money[] bag= { new Money(26, "CHF"), new Money(7, "USD") };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, fMB1.Add(f14CHF));
}
示例4: BagMultiply
public void BagMultiply()
{
// {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]}
Money[] bag = { new Money(24, "CHF"), new Money(14, "USD") };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, fMB1.Multiply(2));
Assert.AreEqual(fMB1, fMB1.Multiply(1));
Assert.IsTrue(fMB1.Multiply(0).IsZero);
}
示例5: SetUp
protected void SetUp()
{
f12CHF= new Money(12, "CHF");
f14CHF= new Money(14, "CHF");
f7USD= new Money( 7, "USD");
f21USD= new Money(21, "USD");
fMB1= new MoneyBag(f12CHF, f7USD);
fMB2= new MoneyBag(f14CHF, f21USD);
}
示例6: MoneyBagEquals
public void MoneyBagEquals()
{
//NOTE: Normally we use Assert.AreEqual to test whether two
// objects are equal. But here we are testing the MoneyBag.Equals()
// method itself, so using AreEqual would not serve the purpose.
Assert.IsFalse(fMB1.Equals(null));
Assert.IsTrue(fMB1.Equals( fMB1 ));
MoneyBag equal= new MoneyBag(new Money(12, "CHF"), new Money(7, "USD"));
Assert.IsTrue(fMB1.Equals(equal));
Assert.IsTrue(!fMB1.Equals(f12CHF));
Assert.IsTrue(!f12CHF.Equals(fMB1));
Assert.IsTrue(!fMB1.Equals(fMB2));
}
示例7: SimpleBagAdd
public void SimpleBagAdd()
{
// [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]}
Money[] bag= { new Money(26, "CHF"), new Money(7, "USD") };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, f14CHF.Add(fMB1));
}
示例8: Normalize4
public void Normalize4()
{
// [12 CHF] - {[12 CHF][3 USD]} == [-3 USD]
Money[] s1 = { new Money(12, "CHF"), new Money(3, "USD") };
MoneyBag ms1= new MoneyBag(s1);
Money expected= new Money(-3, "USD");
Assert.AreEqual(expected, f12CHF.Subtract(ms1));
}
示例9: Normalize3
public void Normalize3()
{
// {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD]
Money[] s1 = { new Money(12, "CHF"), new Money(3, "USD") };
MoneyBag ms1= new MoneyBag(s1);
Money expected= new Money(4, "USD");
Assert.AreEqual(expected, fMB1.Subtract(ms1));
}
示例10: Normalize
public void Normalize()
{
Money[] bag= { new Money(26, "CHF"), new Money(28, "CHF"), new Money(6, "CHF") };
MoneyBag moneyBag= new MoneyBag(bag);
Money[] expected = { new Money(60, "CHF") };
// note: expected is still a MoneyBag
MoneyBag expectedBag= new MoneyBag(expected);
Assert.AreEqual(expectedBag, moneyBag);
}
示例11: AddMoneyBag
public IMoney AddMoneyBag(MoneyBag s)
{
return (new MoneyBag(s, this)).Simplify();
}
示例12: BagSumAdd
public void BagSumAdd()
{
// {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]}
Money[] bag= { new Money(26, "CHF"), new Money(28, "USD") };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, fMB1.Add(fMB2));
}
示例13: MixedSimpleAdd
public void MixedSimpleAdd()
{
// [12 CHF] + [7 USD] == {[12 CHF][7 USD]}
Money[] bag= { f12CHF, f7USD };
MoneyBag expected= new MoneyBag(bag);
Assert.AreEqual(expected, f12CHF.Add(f7USD));
}
示例14: MoneyBag
public MoneyBag(MoneyBag m1, MoneyBag m2)
{
AppendBag(m1);
AppendBag(m2);
}
示例15: AppendBag
private void AppendBag(MoneyBag aBag)
{
foreach (Money m in aBag.fMonies)
AppendMoney(m);
}