当前在线人数12647
首页 - 分类讨论区 - 电脑网络 - 窗口里的风景版 - 同主题阅读文章

此篇文章共收到打赏
0

  • 10
  • 20
  • 50
  • 100
您目前伪币余额:0
未名交友
[更多]
[更多]
cs unit 范例
[版面:窗口里的风景][首篇作者:LodossWar] , 2003年10月17日17:19:21 ,292次阅读,0次回复
来APP回复,赚取更多伪币 关注本站公众号:
[分页:1 ]
LodossWar
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 1 ]

发信人: LodossWar (sleepycat), 信区: DotNet
标  题: cs unit 范例
发信站: Unknown Space - 未名空间 (Fri Oct 17 17:19:21 2003) WWW-POST

抛砖引玉

我在重写MS Petshop.取名叫XPetshop.由于我是test driven programming. Here is the
part of the CS Unit class I wrote.


using System;
using csUnit;

using XPetshop.BLL;
using XPetshop.Model;

namespace UTest
{

/// <summary>
/// [TestFixture]这个attribute说明这个class是Test类。
/// </summary>
[TestFixture]
public class TestBLL
{
private Customer customer1;
private Account ac;

                   //这个attribute说明Initial要在其他test funtion之前执行
[SetUp]
public void Initial()
{
                          //这里的customer是我Unit test的Utility类
                          //用来模拟Use case中的user
customer1  = new Customer();
ac = new Account();
}

/// <summary>
/// [Test]说明这是一个Test method.
/// </summary>
[Test]
public void Account_register()
{
// from customer view, the system should return without exception..

bool b = ac.Register(customer1._userid, customer1._password,
customer1._address);
Assert.True(b);
// from system view, the system should have an inter item correspoing with
this input.

}

[Test]
public void Account_signin()
{
bool b = ac.SignIn(customer1._userid, customer1._password);
Assert.True(b);
}

                   //注意ignore,csUnit不会执行这个Test method.
[Test,Ignore("not completed yet") ]
public void Account_getAddress()
{
AddressInfo address = ac.GetAddress(customer1._userid);
Assert.Equals(customer1._address.FirstName, address.FirstName);
Assert.Equals(customer1._address.LastName, address.LastName);
Assert.Equals(customer1._address.Address1, address.Address1);
Assert.Equals(customer1._address.Address2, address.Address2);
Assert.Equals(customer1._address.City, address.City);
Assert.Equals(customer1._address.State, address.State);
Assert.Equals(customer1._address.Zip, address.Zip);
Assert.Equals(customer1._address.Country, address.Country);
Assert.Equals(customer1._address.Phone, address.Phone);
}

}
}


--
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 151.201.]

 
[分页:1 ]
[快速返回] [ 进入窗口里的风景讨论区] [返回顶部]
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996