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


C# Money.Equals方法代码示例

本文整理汇总了C#中Money.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Money.Equals方法的具体用法?C# Money.Equals怎么用?C# Money.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Money的用法示例。


在下文中一共展示了Money.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldBeEquatableWithNull

        public void ShouldBeEquatableWithNull()
        {
            var money = new Money(42, "AUD");
            var actual = money.Equals(null);

            actual.ShouldBe(false);
        }
开发者ID:zpbappi,项目名称:money,代码行数:7,代码来源:EqualityTest.cs

示例2: op_Equals_objectDiffers

        public void op_Equals_objectDiffers()
        {
            var euro = new Currency("€", 2);

            var obj = new Money(euro, 1.23m);
            var comparand = new Money(euro, 4.56m);

            Assert.False(obj.Equals(comparand));
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:9,代码来源:Money.Facts.cs

示例3: op_Equals_object

        public void op_Equals_object()
        {
            var euro = new Currency("€", 2);

            var obj = new Money(euro, 1.23m);
            var comparand = new Money(euro, 1.23m);

            Assert.True(obj.Equals(comparand));
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:9,代码来源:Money.Facts.cs

示例4: MoneyWithSameCurrency_ShouldBeEquatable

        public void MoneyWithSameCurrency_ShouldBeEquatable(
            decimal amount1,
            decimal amount2,
            bool expected)
        {
            const string currency = "AUD";
            var money1 = new Money(amount1, currency);
            var money2 = new Money(amount2, currency);

            var actual = money1.Equals(money2);

            actual.ShouldBe(expected);
        }
开发者ID:zpbappi,项目名称:money,代码行数:13,代码来源:EqualityTest.cs

示例5: EqualsTest

        public void EqualsTest()
        {
            Currency currency = new Currency("USD", "USD");
            Money target = new Money(100, currency);
            Money other = null;
            bool actual;

            actual = target.Equals(other);
            Assert.AreEqual<bool>(false, actual);

            target = new Money(100, currency);
            other = new Money(100, currency);
            actual = target.Equals(other);
            Assert.AreEqual<bool>(true, actual);

            target = new Money(100, currency);
            other = new Money(0, currency);
            actual = target.Equals(other);
            Assert.AreEqual<bool>(false, actual);

            target = new Money(100, currency);
            other = new Money(100, new Currency("GBP", "GBP"));
            try
            {
                actual = target.Equals(other);
                Assert.Fail("Expected InvalidOperationException");
            }
            catch (InvalidOperationException) { }
        }
开发者ID:robukoo,项目名称:SimpleBankingSystem,代码行数:29,代码来源:MoneyTest.cs

示例6: WhenEquatingTwoDifferentCurrencies_ShouldReturnFalse

        public void WhenEquatingTwoDifferentCurrencies_ShouldReturnFalse(
            decimal amount1,
            string currency1,
            decimal amount2,
            string currency2,
            bool expected)
        {
            var money1 = new Money(amount1, currency1);
            var money2 = new Money(amount2, currency2);

            var actual = money1.Equals(money2);

            actual.ShouldBe(expected);
        }
开发者ID:zpbappi,项目名称:money,代码行数:14,代码来源:EqualityTest.cs

示例7: Money_With_Another_Value_Should_Not_Be_Equal

        public void Money_With_Another_Value_Should_Not_Be_Equal()
        {
            var money1 = new Money(50);
            var money2 = new Money(50.01M);
            var money3 = new Money(-50);

            Assert.NotEqual(money1, money2);
            Assert.NotEqual(money1, money3);

            Assert.False(money1 == money2);
            Assert.True(money1 != money2);
            Assert.False(money1.Equals(money2));
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:13,代码来源:MoneyTests.cs

示例8: Money_With_The_Same_Value_Should_Be_Equal

        public void Money_With_The_Same_Value_Should_Be_Equal()
        {
            var money1 = new Money(50);
            var money2 = new Money(50);

            Assert.Equal(money1, money2);
            Assert.True(money1 == money2);
            Assert.False(money1 != money2);
            Assert.True(money1.Equals(money2));
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:10,代码来源:MoneyTests.cs

示例9: EqualsMoney

        public void EqualsMoney()
        {
            Money money1 = new Money((decimal)10.05, CurrencyFixture.NewZealandDollar);
            Money money2 = new Money((decimal)10.05, CurrencyFixture.NewZealandDollar);
            Money money3 = new Money((decimal)10.05, CurrencyFixture.NewZealandDollar);

            Assert.IsTrue(money1.Equals(money1));

            Assert.IsTrue(money1.Equals(money2));
            Assert.IsTrue(money2.Equals(money1));
            Assert.IsTrue(money1.Equals(money2) && money2.Equals(money3));

            Assert.IsFalse(money1.Equals(null));
        }
开发者ID:jonocairns,项目名称:csharp-money,代码行数:14,代码来源:MoneyTest.cs

示例10: EqualsMethodReturnsFalseWhenMoneyHasDifferentCurrencies

        public void EqualsMethodReturnsFalseWhenMoneyHasDifferentCurrencies()
        {
            Money aud = new Money(12.5m, CurrencyFixture.AustralianDollar);
            Money nzd = new Money(12.5m, CurrencyFixture.NewZealandDollar);

            aud.Equals(nzd).Should().Be(false);
        }
开发者ID:jonocairns,项目名称:csharp-money,代码行数:7,代码来源:MoneyTest.cs


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