本文整理汇总了C#中Money.Allocate方法的典型用法代码示例。如果您正苦于以下问题:C# Money.Allocate方法的具体用法?C# Money.Allocate怎么用?C# Money.Allocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money
的用法示例。
在下文中一共展示了Money.Allocate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllocateTest1
public void AllocateTest1()
{
var target = new Money(100);
var ratios = new[] { 0.2m };
var expected = new[] { (Money)100 };
Money[] actual = target.Allocate(ratios);
for (int i = 0; i < ratios.Length; ++i)
Assert.AreEqual(expected[i], actual[i]);
}
示例2: TestAllocation
public void TestAllocation()
{
var money1 = new Money(10, CurrencyCodes.ZAR);
var allocatedMoney1 = money1.Allocate(3);
var total1 = new Money(CurrencyCodes.ZAR);
total1 = allocatedMoney1.Aggregate(total1, (current, t) => current + t);
Assert.AreEqual("R10,00", total1.ToString());
Assert.AreEqual("R3,34", allocatedMoney1[0].ToString());
Assert.AreEqual("R3,33", allocatedMoney1[1].ToString());
Assert.AreEqual("R3,33", allocatedMoney1[2].ToString());
var money2 = new Money(0.09m, CurrencyCodes.USD);
var allocatedMoney2 = money2.Allocate(5);
var total2 = new Money(CurrencyCodes.USD);
total2 = allocatedMoney2.Aggregate(total2, (current, t) => current + t);
Assert.AreEqual("$0.09", total2.ToString());
}