首页 新闻 会员 周边

Moq 初级问题

0
[待解决问题]

我刚刚接触MOQ。看了http://www.cnblogs.com/wJiang/category/234081.html这个博客。但是我怎么也建不起来。我写了

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MoqTest.Dal.Interface
{
    public interface IUser
    {
         string GetAllUser();
    }
}这样一个接口,

写了一个

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MoqTest.Dal.Interface;
using Moq;
using Microsoft;

namespace MoqTest.Dal.Realize
{
    public class User
    {
        [TestMethod()]

        private void MoqTest()
        {
            var mo = new Mock<IUser>();
            mo.Setup(p => p.GetAllUser()).Returns("123");
            Assert.AreEqual("lfm", mo.Object.GetAllUser());

        }

    }
}

这样的测试方法

但是它一直报我错

错误 1 找不到类型或命名空间名称“TestMethodAttribute”(是否缺少 using 指令或程序集引用?) F:\20100724同程\MOQ\MoqTest\MoqTest.Dal\Realize\User.cs 13 10 MoqTest.Dal

错误 2 找不到类型或命名空间名称“TestMethod”(是否缺少 using 指令或程序集引用?) F:\20100724同程\MOQ\MoqTest\MoqTest.Dal\Realize\User.cs 13 10 MoqTest.Dal
错误 6 当前上下文中不存在名称“Assert” F:\20100724同程\MOQ\MoqTest\MoqTest.Dal\Realize\User.cs 19 13 MoqTest.Dal
这三个错。我想应该是我少引用了什么。但是网上搜了没搜到。

我用的是VS2008 MOQ是3.1的。用的是简单三层。这个是在数据访问层写的。各位大侠帮帮忙啊。

问题补充: 各位如果有这方面的完整实例可不可以发一个到我邮箱啊? wywy12300@163.com 再次谢谢各位
小高的主页 小高 | 初学一级 | 园豆:200
提问于:2010-09-13 21:36
< >
分享
所有回答(1)
1

在你解决方案中,右键-添加-新建项目,选择测试项目

悍马奔野 | 园豆:212 (菜鸟二级) | 2010-12-22 14:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册