Esempio n. 1
0
        public void TestGetWithNSub()
        {
            var rtnForGetAll = new List <User>()
            {
                new User()
                {
                    Name = "Amigo", DepartmentId = 1, Department = new Department()
                    {
                        Name = "開發二課"
                    }
                },
                new User()
                {
                    Name = "Ariel", DepartmentId = 1, Department = new Department()
                    {
                        Name = "開發一課"
                    }
                },
                new User()
                {
                    Name = "Frank", DepartmentId = 1, Department = new Department()
                    {
                        Name = "開發一課"
                    }
                }
            };

            IDalService dalService = Substitute.For <IDalService>();

            dalService.GetAll().Returns(rtnForGetAll.AsEnumerable());

            var entities = dalService.GetAll();

            foreach (var entity in entities)
            {
                Debug.WriteLine(String.Format("Name:{0}, Department:{1}", entity.Name, entity.Department.Name));
            }

            Debug.WriteLine("Finish");
            //The real test here ....
        }