コード例 #1
0
        public void Should_rely_on_values_for_unicity()
        {
            var goodTill      = DateTime.Now;
            var dtoIdentifier = new InvestorInstructionIdentifierDto();

            var instruction          = new InvestorInstructionDto(dtoIdentifier, Way.Buy, 1, 1.1M, true, goodTill);
            var identicalInstruction = new InvestorInstructionDto(dtoIdentifier, Way.Buy, 1, 1.1M, true, goodTill);
            var dictionary           = new Dictionary <InvestorInstructionDto, int>();

            dictionary[instruction]          = 2;
            dictionary[identicalInstruction] = 3;

            Check.That(dictionary[instruction]).IsEqualTo(3);
        }
コード例 #2
0
        public void Should_rely_on_values_for_equality()
        {
            var       investorInstructionIdentifier = 42;
            const Way Way      = Way.Buy;
            var       quantity = 1;
            var       price    = 23.3M;
            var       allowPartialExecution = true;
            var       goodTill = DateTime.Now;

            var dtoIdentifier              = new InvestorInstructionIdentifierDto();
            var firstInstruction           = new InvestorInstructionDto(dtoIdentifier, Way, quantity, price, allowPartialExecution, goodTill);
            var secondIdenticalInstruction = new InvestorInstructionDto(dtoIdentifier, Way, quantity, price, allowPartialExecution, goodTill);

            Check.That(firstInstruction).IsEqualTo(secondIdenticalInstruction);

            allowPartialExecution = false;
            var slightlyDifferentInstruction = new InvestorInstruction(investorInstructionIdentifier, Way, quantity, price, allowPartialExecution, goodTill);

            Check.That(slightlyDifferentInstruction).IsNotEqualTo(firstInstruction);
        }