Esempio n. 1
0
        public void Sample_MethodWithLambda()
        {
            dynamic accountingRepository = new DynamicMock();

            accountingRepository.GetCashFlowByCriteria(If(c => c.RequestHashCode == 1)).Returns(10m);
            accountingRepository.GetCashFlowByCriteria(If(c => c.RequestHashCode == 2)).Returns(20m);
            accountingRepository.GetCashFlowByCriteria(If(c => c.RequestHashCode == 3)).Returns(30m);

            IAccountingRepository result = accountingRepository;

            var actual1 = result.GetCashFlowByCriteria(new AccountingInvestmentValidationCriteria {
                RequestHashCode = 1
            });
            var actual2 = result.GetCashFlowByCriteria(new AccountingInvestmentValidationCriteria {
                RequestHashCode = 2
            });
            var actual3 = result.GetCashFlowByCriteria(new AccountingInvestmentValidationCriteria {
                RequestHashCode = 3
            });

            Assert.AreEqual(10, actual1);
            Assert.AreEqual(20, actual2);
            Assert.AreEqual(30, actual3);
        }