Exemple #1
0
        public void 呼叫_ILogDao_DebugObj_DebugCollection_次數1_參數為參考型別()
        {
            var condition = new QueryCondition {
                Keyword = "3"
            };

            IDao dao = Substitute.For <IDao>();

            dao.QueryCondition(condition)
            .Returns(new List <DTO>
            {
                new DTO
                {
                    Id   = 3,
                    Name = "C"
                }
            });

            ILogDao logDao = Substitute.For <ILogDao>();

            var target = new BL(dao, logDao);

            target.Query(condition);

            // test success:reference equal
            // logDao.Received(1).DebugObject(condition);

            // test fail
            //var expectedCondition = new QueryCondition { Keyword = "3" };
            //logDao.Received(1).DebugObject(expectedCondition);

            logDao.Received(1).DebugObject(Arg.Is <QueryCondition>(x => QueryConditionIsEqual(x, condition)));
        }
Exemple #2
0
        public void 呼叫_ILogDao_Debug_次數1()
        {
            IDao dao = Substitute.For <IDao>();

            dao.Query().Returns(new List <DTO>
            {
                new DTO
                {
                    Id   = 1,
                    Name = "A"
                },
                new DTO
                {
                    Id   = 2,
                    Name = "B"
                }
            });

            ILogDao logDao = Substitute.For <ILogDao>();

            new BL(dao, logDao).Query();

            //logDao.ReceivedWithAnyArgs(2).Debug(string.Empty);

            //logDao.ReceivedWithAnyArgs(1).Debug(string.Empty);

            logDao.Received(1).Debug("No Condition QueryCondition");
        }