AutoMocker单元测试

/// <summary>
        /// 测试获取所有物流
        /// </summary>
        [TestMethod]
        public void TestExpressController()
        {
            var Expresss = new List<Express> { 
                new Express{Code="01",Name="测试物流"}
            }.AsQueryable();

            var mocker = new AutoMocker();
            mocker.Use<IExpressContract>(x => x.Entities == Expresss);
            var controller = mocker.CreateInstance<ExpressController>();
            controller.ExpressContract = mocker.Get<IExpressContract>();

            var result = controller.Get();

            Assert.IsNotNull(result);
            Assert.AreEqual(ReslultCode.sucess, result.code);
            Assert.AreEqual("01", result.Data.ElementAt(0).ExpressCode);
            Assert.AreEqual("测试物流", result.Data.ElementAt(0).ExpressName);
        }

 

posted @ 2016-06-15 17:02  shiningrise  阅读(568)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css