public VO[] Query(QueryCondition condition) { _logDao?.DebugObject(condition); var dtos = _dao?.QueryCondition(condition); var vos = dtos?.Select(d => d.ToVO()).ToArray() ?? new VO[0]; _logDao?.DebugCollection(vos.Select(vo => vo.Id).ToArray()); return(vos); }
public void 呼叫_參數為IEnumerable() { IEnumerable <int> ids = new[] { 5 }; IDao dao = Substitute.For <IDao>(); // 如果 predicate deletegate 回傳是 true 時,就會回傳 Returns() 裡面所指定的 物件 dao.QueryCondition(Arg.Is <IEnumerable <int> >(x => IdsAreEqual(x, ids))) .Returns(new List <DTO> { new DTO { Id = 5, Name = "E" } }); ILogDao logDao = Substitute.For <ILogDao>(); IEnumerable <int> actualCollection = null; logDao.DebugCollection(Arg.Do <int[]>(x => actualCollection = x)); var target = new BL(dao, logDao); var conditions = new List <VO> { new VO { Id = 5 } }; target.Query(conditions); IEnumerable <int> expectedCollection = new[] { 5 }; actualCollection.Should().BeEquivalentTo(expectedCollection); }