vs2013c#测试using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1_CXY { class Program { stati
首先安装Unit Test Generator。
方法为:工具->扩展和更新->联机->搜索“图标为装有蓝色液体的小试管。
Unit Test
Generator”,
编写代码,生成一个新的类,编写构造函数 与 add()函数。代码如下。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication1_CXY
{
class Program
{
static void Main(string[] args)
{
}
}
public class test
{
public test(){ }
public int add(int a,int b)
{
return a + b;
}
}
}
在addTest()函数里编写测试代码,代码如下。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApplication1_CXY;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ConsoleApplication1_CXY.Tests
{
[TestClass()]
public class testTests
{
[TestMethod()]
public void addTest()
{
int a=2,b=5,expect=7;
test t = new test();
int real = t.add(a,b); Assert.AreEqual(real,expect);
//Assert.Fail();
}
}
}
测试结果如图所示:

如此就完成了一个简单的c#测试。
vs2013c#测试using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1_CXY { class Program { stati的更多相关文章
- 无法将类型“System.Collections.Generic.IEnumerable<EmailSystem.Model.TemplateInfo>”隐式转换为“System.Collections.Generic.List<EmailSystem.Model.TemplateInf
List<Model.Template> templateList = templateBLL.RecommendTemplateByOrder(modelEbay); List<M ...
- C#:system.collections.generic(泛型)
1. array是一个固定长度的,如果要动态的存储的话就不行了,虽然 System.Collections.ArrayList(),是一个动态的存储的容器,但是没有对存储中的数据进行一个约束,所以非泛 ...
- HttpClient exception:ExceptionType:System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: Operation ca
error msg: System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System. ...
- 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转换为类型“System.Collections.Generic.IList`1
在WPF中DataGrid 选择事件中获取SelectedItems 报错如下 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转 ...
- webservice asmx 无法序列化接口 System.Collections.Generic.IList
转载自:http://www.cnblogs.com/chenhuzi/p/4178194.html 今天有位同事在方法里加了一个IList<entity> 的返回值,也没有测试,直接发布 ...
- Web Service接口返回泛型的问题(System.InvalidCastException: 无法将类型为“System.Collections.Generic.List`1[System.String]”的对象强制转换为类型“System.String[]”)
在使用C#写Web Service时遇到了个很奇怪的问题.返回值的类型是泛型(我用的是类似List<string>)的接口,测试时发现总是报什么无法转换为对象的错误,百思不得其解. 后来在 ...
- 无法将类型“System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>”隐式转换为“System.Collections.Generic.List<Ecology.Model.EnergyFlowGraph>”
无法将类型“System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>”隐式转换为“Sy ...
- System.Collections.Generic的各容器类的用法
演示System.Collections.Generic的各容器类的用法. 包括:Dictionary,KeyValuePair,SortedDic tionary,SortedList,HashSe ...
- NHibernate无法将类型“System.Collections.Generic.IList<T>”隐式转换为“System.Collections.Generic.IList<IT>
API有一个需要实现的抽象方法: public IList<IPermission> GetPermissions(); 需要注意的是IList<IPermission>这个泛 ...
随机推荐
- linux 的常用命令---------第四阶段
权限管理 “4” “r” → 读权限: 查看文件内容: 是否能够列出目录结构. “2” “w” → 写权限: 编辑文件内容: 是否能够创建.删除.复制.移动目录. “1” “x” → 执行权限: 对二 ...
- Docker技术入门与实战 第二版-学习笔记-5-容器-命令及限制内存与cpu资源
1.启动容器 启动容器有两种方式: 基于镜像新建一个容器并启动 将在终止状态(stopped)的容器重新启动 1)新建并启动——docker run 比如在启动ubuntu:14.04容器,并输出“H ...
- JAVA框架 Spring 引入多个配置文件
1.如果配置文件比较长,可以分多个配置文件.有两种方式: 1)在主配置文件加标签<import/> <import resource="jd/com/other/appli ...
- Theano3.7-练习之堆叠消噪自动编码器
来自:http://deeplearning.net/tutorial/SdA.html#sda Stacked Denoising Autoencoders (SdA) note:这部分需要读者读过 ...
- SVN之 trunk, branches and tags意义
--简单的对照 SVN的工作机制在某种程度上就像一颗正在生长的树: 一颗有树干和很多分支的树 分支从树干生长出来.而且细的分支从相对较粗的树干中长出 一棵树能够仅仅有树干没有分支(可是这样的情况不会持 ...
- Scala--映射和元组
一.构造映射 val scores = Map("Jim"->10, ("Tom",20), "Sam"->44) //key- ...
- 开源PaaS工具CloudFoundry落地阿里云
原文:https://yq.aliyun.com/articles/292815?utm_content=m_37457 云计算技术的不断成熟和完善,尤其是IaaS平台的不断发展,使得越来越多的企业和 ...
- 2017-2018-2 20155231《网络对抗技术》实验八: WEB基础实验
2017-2018-2 20155231<网络对抗技术>实验八:Web基础 实验要求: Web前端HTML(0.5分) 能正常安装.启停Apache.理解HTML,理解表单,理解GET与P ...
- 20155333 《网络对抗》 Exp7 网络欺诈防范
20155333 <网络对抗> Exp7 网络欺诈防范 基础问题 通常在什么场景下容易受到DNS spoof攻击? 公共网络 在日常生活工作中如何防范以上两种攻击方法? DNS欺骗攻击是很 ...
- JavaEE笔记(十二)
代理的三种配置 beans配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=& ...