コード例 #1
0
        public void Find_equals_2_different_instances_of_ValueType_with_different_values_when_equality_is_badly_implemented()
        {
            var itemPrice = new ItemPriceWithBadImplementationForEqualityAndUnicity("movie", new decimal(50.3), Currency.Dollar);
            var differentItemPriceValue = new ItemPriceWithBadImplementationForEqualityAndUnicity("not a movie", new decimal(50.3), Currency.Dollar);

            Check.That(itemPrice).IsEqualTo(differentItemPriceValue); // because bad implementation of equality
        }
コード例 #2
0
        public void Retrieve_wrong_instances_from_a_set_when_unicity_is_badly_implemented_on_a_derived_value_type()
        {
            var itemPrice = new ItemPriceWithBadImplementationForEqualityAndUnicity("movie", new decimal(50.3), Currency.Dollar);
            var itemPriceWithOtherValues = new ItemPriceWithBadImplementationForEqualityAndUnicity("XXX movie", new decimal(50.3), Currency.Dollar);

            var set = new HashSet <ItemPriceWithBadImplementationForEqualityAndUnicity> {
                itemPrice
            };

            Check.That(set).ContainsExactly(itemPriceWithOtherValues); // because bad implementation of unicity
        }